From 4a5b3821b6ce6f0c96cee20c506670c87a0b7cdd Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Thu, 26 Jan 2023 07:15:31 +0100 Subject: [PATCH] RUST: Update included dependencies --- src/rust/Cargo.lock | 52 ++++++++++++++++++++++++++++-- src/rust/Cargo.toml | 2 ++ src/rust/getset/Cargo.toml | 14 ++------ src/rust/getset/examples/simple.rs | 24 -------------- src/rust/smallstring/Cargo.toml | 3 +- src/rust/smallstring/src/lib.rs | 15 +++------ 6 files changed, 62 insertions(+), 48 deletions(-) delete mode 100644 src/rust/getset/examples/simple.rs diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock index 71b24288..9b67a7a8 100644 --- a/src/rust/Cargo.lock +++ b/src/rust/Cargo.lock @@ -2,6 +2,17 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + [[package]] name = "amadeus" version = "0.1.0" @@ -19,7 +30,9 @@ version = "0.1.0" dependencies = [ "commons", "getset", + "lru", "serde", + "smallstring", "tokio", ] @@ -262,7 +275,7 @@ dependencies = [ [[package]] name = "getset" -version = "0.1.2" +version = "0.1.3" dependencies = [ "proc-macro-error", "proc-macro2", @@ -295,6 +308,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "heck" version = "0.4.0" @@ -398,7 +420,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -541,6 +563,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e7d46de488603ffdd5f30afbc64fbba2378214a2c3a2fb83abf3d33126df17" +dependencies = [ + "hashbrown 0.13.2", +] + [[package]] name = "memchr" version = "2.5.0" @@ -897,6 +928,23 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smallstring" +version = "0.1.3" +dependencies = [ + "serde", + "smallvec", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +dependencies = [ + "serde", +] + [[package]] name = "socket2" version = "0.4.7" diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml index 5b2fdfea..79db8e61 100644 --- a/src/rust/Cargo.toml +++ b/src/rust/Cargo.toml @@ -31,6 +31,8 @@ libc = "0.2" lazy_static = "^1" thiserror = "^1" +smallvec = { version = "^1", default-features = false, features = ["serde"] } + toml = { version = "^0.5", features = ["preserve_order"] } serde = { version = "^1", default-features = false, features = [ "std", diff --git a/src/rust/getset/Cargo.toml b/src/rust/getset/Cargo.toml index b6b65079..0f46a462 100644 --- a/src/rust/getset/Cargo.toml +++ b/src/rust/getset/Cargo.toml @@ -1,19 +1,11 @@ [package] name = "getset" -description = """ -Getset, we're ready to go! - -A procedural macro for generating the most basic getters and setters on fields. -""" -version = "0.1.2" +description = "A procedural macro for generating the most basic getters and setters on fields." +version = "0.1.3" authors = ["Ana Hobden <ana@hoverbear.org>"] license = "MIT" -edition = "2018" -categories = ["development-tools::procedural-macro-helpers"] -keywords = ["macro", "getter", "setter", "getters", "setters"] -readme = "README.md" -repository = "https://github.com/Hoverbear/getset" +edition.workspace = true [lib] proc-macro = true diff --git a/src/rust/getset/examples/simple.rs b/src/rust/getset/examples/simple.rs deleted file mode 100644 index 62f072f3..00000000 --- a/src/rust/getset/examples/simple.rs +++ /dev/null @@ -1,24 +0,0 @@ -use getset::{CopyGetters, Getters, MutGetters, Setters}; - -#[derive(Getters, Setters, MutGetters, CopyGetters, Default)] -pub struct Foo<T> -where - T: Copy + Clone + Default, -{ - /// Doc comments are supported! - /// Multiline, even. - #[getset(get, set, get_mut)] - private: T, - - /// Doc comments are supported! - /// Multiline, even. - #[getset(get_copy = "pub", set = "pub", get_mut = "pub")] - public: T, -} - -fn main() { - let mut foobar = Foo::default(); - foobar.set_private(1); - (*foobar.private_mut()) += 1; - assert_eq!(*foobar.private(), 2); -} diff --git a/src/rust/smallstring/Cargo.toml b/src/rust/smallstring/Cargo.toml index d88521f6..19a1f681 100644 --- a/src/rust/smallstring/Cargo.toml +++ b/src/rust/smallstring/Cargo.toml @@ -8,4 +8,5 @@ license = "MIT" edition.workspace = true [dependencies] -smallvec = { version = "^1", default-features = false } +smallvec.workspace = true +serde.workspace = true diff --git a/src/rust/smallstring/src/lib.rs b/src/rust/smallstring/src/lib.rs index 9fb47d75..e76a1ae2 100644 --- a/src/rust/smallstring/src/lib.rs +++ b/src/rust/smallstring/src/lib.rs @@ -8,7 +8,7 @@ use std::{ }; // TODO: FromIterator without having to allocate a String -#[derive(Clone, Default)] +#[derive(Clone, Default, serde::Serialize, serde::Deserialize)] pub struct SmallString<B: Array<Item = u8> = [u8; 8]> { buffer: SmallVec<B>, } @@ -94,9 +94,7 @@ impl<I: Iterator<Item = char>> Iterator for Utf8Iterator<I> { } } - let out = self.0.next(); - - out.and_then(|chr| { + self.0.next().and_then(|chr| { let mut dest = [0u8; 4]; let outstr = chr.encode_utf8(&mut dest); @@ -115,19 +113,14 @@ impl<I: Iterator<Item = char>> Iterator for Utf8Iterator<I> { fn size_hint(&self) -> (usize, Option<usize>) { let hint = self.0.size_hint(); - (hint.0, hint.1.map(|x| x * 4)) } } impl FromIterator<char> for SmallString { fn from_iter<T: IntoIterator<Item = char>>(into_iter: T) -> Self { - // We're a shell so we mostly work with ASCII data - optimise for this - // case since we have to optimise for _some_ fixed size of char. - let utf8 = Utf8Iterator::new(into_iter); - SmallString { - buffer: utf8.collect(), + buffer: Utf8Iterator::new(into_iter).collect(), } } } @@ -157,6 +150,8 @@ impl From<String> for SmallString { impl From<SmallString> for String { fn from(s: SmallString) -> String { + // We only allow `buffer` to be created from an existing valid string, + // so this is safe. unsafe { String::from_utf8_unchecked(s.buffer.into_vec()) } } } -- GitLab