Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Make Path and PathBuf more const-friendly and release v0.1.1 #89

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

robin-nitrokey
Copy link
Member

This patch makes some Path and PathBuf methods const, adds new const helper functions and a path_buf macro similar to the existing path and releases littlefs2-core v0.1.1 with these changes.

This patch makes Path and PathBuf more const-friendly by adding some new
const methods and marking existing methods as const.
We already have the path macro and PathBuf::from_path.  Having a
separate path_buf macro makes the code more readable and ensures
compile-time evaluation.
Comment on lines +98 to +104
const _PATH: $crate::PathBuf =
match $crate::Path::from_str_with_nul(::core::concat!($path, "\0")) {
Ok(path) => $crate::PathBuf::from_path(path),
Err(_) => panic!("invalid littlefs2 path"),
};
_PATH
}};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it purposefully not using an inline const block?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think the workaround is simple enough to avoid bumping the MSRV just for inline const blocks.

@robin-nitrokey robin-nitrokey merged commit c31e789 into main Jan 17, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants