Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 16 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "smallvec"
version = "2.0.0-beta.3"
edition = "2024"
rust-version = "1.86"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
license.workspace = true
repository = "https://github.com/servo/rust-smallvec"
description = "'Small vector' optimization: store up to a small number of items on the stack"
keywords = ["small", "vec", "vector", "stack", "no_std"]
Expand All @@ -18,26 +18,20 @@ opt-level = 3
debug = false
strip = true

# Dedicated profile for the iai-callgrind benchmarks. Callgrind needs the
# function symbols in the binary to attribute event counts, so we disable
# stripping (and keep debug info for line-level detail). Without symbols the
# runner collects zero events for every benchmark. LTO is left on (inherited)
# since it does not affect collection and keeps the run representative.
[profile.callgrind]
inherits = "bench"
debug = 1
debug = true
strip = false

[features]
allocator-api = []
allocator-api2 = ["dep:allocator-api2", "allocator-api"]
allocator-api2 = ["allocator-api", "dep:allocator-api2"]
internals = []
proptest = ["dep:proptest", "std"]
rayon = ["std", "dep:rayon"]
rayon = ["dep:rayon", "std"]
serde = ["dep:serde_core"]
specialization = []
std = []
zeroize = ["dep:zeroize"]

[dependencies]
allocator-api2 = { version = "0.4", optional = true, features = ["alloc"], default-features = false }
Expand All @@ -50,12 +44,13 @@ malloc_size_of = { version = "0.1", optional = true, default-features = false }
proptest = { version = "1.11", optional = true, features = ["std"], default-features = false }
rayon = { version = "1.12", optional = true, default-features = false }
serde_core = { version = "1.0", optional = true, default-features = false }
syntax = { path = "./syntax" }
zeroize = { version = "1.9", optional = true, default-features = false }

[dev-dependencies]
serde_test = "1.0"
criterion = "0.8"
iai-callgrind = "0.14"
iai-callgrind = "0.16"

[[test]]
name = "arbitrary"
Expand Down Expand Up @@ -104,7 +99,14 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[workspace]
package.edition = "2024"
package.authors = ["The Servo Project Developers"]
package.license = "MIT OR Apache-2.0"
package.repository = "https://github.com/servo/rust-smallvec"
package.rust-version = "1.86"
resolver = "3"
members = [
".",
"fuzz",
"syntax"
]
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@ v.sort();
> [!NOTE]
>
> - SmallVec without any features enabled does not make use of the standard library.
> - The `rayon` feature implicitly requires `std`.
> - The `allocator-api2` feature requires `allocator-api`
> - The `rayon` and `proptest` features implicitly require `std`.
> - The `allocator-api2` feature requires `allocator-api`, though it does not
require `nightly`
9 changes: 6 additions & 3 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[package]
name = "smallvec-fuzz"
name = "fuzzer"
version = "0.0.0"
authors = ["The Servo Project Developers"]
authors.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true
description = "Fuzzer for SmallVec"
publish = false
edition = "2024"

[package.metadata]
cargo-fuzz = true
Expand Down
10 changes: 3 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,10 @@ use {
drop_in_place
}
},
newrange::NewRange
newrange::NewRange,
syntax::syntax
};
#[cfg(feature = "internals")]
pub use {
locatedlength::LocatedLength,
rawsmallvec::RawSmallVec
};
#[cfg(not(feature = "internals"))]
#[cfg_attr(feature = "internals", syntax(pub))]
use {
locatedlength::LocatedLength,
rawsmallvec::RawSmallVec
Expand Down
16 changes: 16 additions & 0 deletions syntax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "syntax"
version = "0.0.0"
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
description = "Syntax macro for SmallVec"
publish = false

[lib]
proc-macro = true
path = "./lib.rs"

[dependencies]
25 changes: 25 additions & 0 deletions syntax/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use proc_macro::{
Delimiter,
TokenStream,
TokenTree
};

#[proc_macro_attribute]
pub fn syntax(attr: TokenStream, item: TokenStream) -> TokenStream {
let mut item_attrs = Vec::<TokenTree>::new();
let mut iter = item.into_iter().fuse();
loop {
match [iter.next(), iter.next()] {
[Some(TokenTree::Punct(p)), Some(TokenTree::Group(g))]
if (p.as_char(), g.delimiter()) == ('#', Delimiter::Bracket) =>
{
item_attrs.extend([p.into(), g.into()]);
}
mut trees => {
let trees = trees.iter_mut().flat_map(Option::take);
item_attrs.extend(attr.into_iter().chain(trees).chain(iter));
return item_attrs.into_iter().collect();
}
};
}
}
Loading