1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 00:01:11 +01:00

add static assertions to bytestring

This commit is contained in:
Rob Ede 2021-11-25 03:29:30 +00:00
parent a2437eed29
commit 18eced7305
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
2 changed files with 23 additions and 4 deletions

View File

@ -10,7 +10,6 @@ keywords = ["string", "bytes", "utf8", "web", "actix"]
categories = ["no-std", "web-programming"] categories = ["no-std", "web-programming"]
homepage = "https://actix.rs" homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"
documentation = "https://docs.rs/bytestring"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2018" edition = "2018"
@ -23,6 +22,6 @@ bytes = "1"
serde = { version = "1.0", optional = true } serde = { version = "1.0", optional = true }
[dev-dependencies] [dev-dependencies]
ahash = { version = "0.7.6", default-features = false }
serde_json = "1.0" serde_json = "1.0"
# TODO: remove when ahash MSRV is restored static_assertions = "1.1"
ahash = { version = "=0.7.4", default-features = false }

View File

@ -2,6 +2,7 @@
#![no_std] #![no_std]
#![deny(rust_2018_idioms, nonstandard_style)] #![deny(rust_2018_idioms, nonstandard_style)]
#![warn(missing_docs)]
#![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_logo_url = "https://actix.rs/img/logo.png")]
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
@ -217,17 +218,36 @@ mod serde {
String::deserialize(deserializer).map(ByteString::from) String::deserialize(deserializer).map(ByteString::from)
} }
} }
#[cfg(test)]
mod serde_impl_tests {
use super::*;
use serde::de::DeserializeOwned;
use static_assertions::assert_impl_all;
assert_impl_all!(ByteString: Serialize, DeserializeOwned);
}
} }
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use alloc::borrow::ToOwned; use alloc::borrow::ToOwned;
use core::hash::{Hash, Hasher}; use core::{
hash::{Hash, Hasher},
panic::{RefUnwindSafe, UnwindSafe},
};
use ahash::AHasher; use ahash::AHasher;
use static_assertions::assert_impl_all;
use super::*; use super::*;
assert_impl_all!(ByteString: Send, Sync, Unpin, Sized);
assert_impl_all!(ByteString: UnwindSafe, RefUnwindSafe);
assert_impl_all!(ByteString: Clone, Default, Eq, PartialOrd, Ord);
assert_impl_all!(ByteString: fmt::Debug, fmt::Display);
#[test] #[test]
fn test_partial_eq() { fn test_partial_eq() {
let s: ByteString = ByteString::from_static("test"); let s: ByteString = ByteString::from_static("test");