diff --git a/Cargo.lock b/Cargo.lock index b6ff067..253a327 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -200,6 +200,37 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "defmt" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1" +dependencies = [ + "bitflags", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8" +dependencies = [ + "defmt-parser", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "defmt-parser" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" +dependencies = [ + "thiserror", +] + [[package]] name = "either" version = "1.18.0" @@ -525,6 +556,7 @@ dependencies = [ "borsh", "bytes", "criterion", + "defmt", "malloc_size_of", "serde_core", "serde_test", @@ -558,6 +590,26 @@ version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" +[[package]] +name = "thiserror" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.3", +] + [[package]] name = "tinytemplate" version = "1.2.1" diff --git a/Cargo.toml b/Cargo.toml index 5d4fb1c..db5fa38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,6 @@ 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"] categories = ["data-structures"] -readme = "README.md" -documentation = "https://docs.rs/smallvec/" exclude = [".gitignore", "tests/", "fuzz/", "benches/", ".github/"] [features] @@ -21,15 +19,16 @@ serde = ["dep:serde_core"] internals = [] [dependencies] -arbitrary = { version = "1", optional = true, default-features = false } +arbitrary = { version = "1.4", optional = true, default-features = false } borsh = { version = "1.8", optional = true, default-features = false } -bytes = { version = "1", optional = true, default-features = false } -serde_core = { version = "1.0.221", optional = true, default-features = false } -malloc_size_of = { version = "0.1.1", optional = true, default-features = false } +bytes = { version = "1.12", optional = true, default-features = false } +defmt = { version = "1.1", optional = true, default-features = false} +serde_core = { version = "1.0", optional = true, default-features = false } +malloc_size_of = { version = "0.1", optional = true, default-features = false } [dev-dependencies] serde_test = "1.0" -criterion = "0.4.0" +criterion = "0.4" [[test]] name = "arbitrary" diff --git a/src/lib.rs b/src/lib.rs index 7a5b656..de6c3f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,9 +60,9 @@ #![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))] #[doc(hidden)] -pub extern crate alloc; +extern crate alloc; -#[cfg(any(test, feature = "std"))] +#[cfg(feature = "std")] extern crate std; #[cfg(feature = "borsh")] @@ -74,6 +74,12 @@ use bytes::{ BufMut, buf::UninitSlice }; +#[cfg(feature = "defmt")] +use defmt::{ + Format, + Formatter as DeFormatter, + write as dewrite +}; #[cfg(feature = "malloc_size_of")] use malloc_size_of::{ MallocShallowSizeOf, @@ -3201,3 +3207,10 @@ unsafe impl BufMut for SmallVec { self.resize(new_len, val); } } + +#[cfg(feature = "defmt")] +impl Format for SmallVec { + fn format(&self, fmt: DeFormatter) { + dewrite!(fmt, "{=[?]}", self.as_ref()); + } +}