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

Make Slab::new const on Rust 1.39+, Use #[track_caller] on Rust 1.46+ #119

Merged
merged 2 commits into from
Jul 9, 2022

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Jul 9, 2022

Closes #87
Closes #90

@taiki-e taiki-e requested review from hawkw and Darksonn July 9, 2022 07:05
Comment on lines +228 to +231
#[cfg(not(slab_no_const_vec_new))]
pub const fn new() -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

The fact that const depends on the version should probably be documented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated docs.

pub fn new() -> Slab<T> {
Slab::with_capacity(0)
#[cfg(not(slab_no_const_vec_new))]
pub const fn new() -> Self {
Copy link

Choose a reason for hiding this comment

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

You could use the const-fn crate here to avoid code deduplication.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is my crate, but it doesn't yet implement the behavior I want.

slab/build.rs

Lines 15 to 17 in 56e7947

// Note that this is `no_`*, not `has_*`. This allows treating as the latest
// stable rustc is used when the build script doesn't run. This is useful
// for non-cargo build systems that don't run the build script.

@taiki-e taiki-e merged commit 42c7f1a into master Jul 9, 2022
@taiki-e taiki-e deleted the rollup branch July 9, 2022 17:21
@taiki-e taiki-e mentioned this pull request Jul 19, 2022
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.

3 participants