mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-23 22:51:07 +01:00
add static assertions to bytestring
This commit is contained in:
parent
a2437eed29
commit
18eced7305
@ -10,7 +10,6 @@ keywords = ["string", "bytes", "utf8", "web", "actix"]
|
||||
categories = ["no-std", "web-programming"]
|
||||
homepage = "https://actix.rs"
|
||||
repository = "https://github.com/actix/actix-net.git"
|
||||
documentation = "https://docs.rs/bytestring"
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
@ -23,6 +22,6 @@ bytes = "1"
|
||||
serde = { version = "1.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
ahash = { version = "0.7.6", default-features = false }
|
||||
serde_json = "1.0"
|
||||
# TODO: remove when ahash MSRV is restored
|
||||
ahash = { version = "=0.7.4", default-features = false }
|
||||
static_assertions = "1.1"
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#![no_std]
|
||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||
#![warn(missing_docs)]
|
||||
#![doc(html_logo_url = "https://actix.rs/img/logo.png")]
|
||||
#![doc(html_favicon_url = "https://actix.rs/favicon.ico")]
|
||||
|
||||
@ -217,17 +218,36 @@ mod serde {
|
||||
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)]
|
||||
mod test {
|
||||
use alloc::borrow::ToOwned;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::{
|
||||
hash::{Hash, Hasher},
|
||||
panic::{RefUnwindSafe, UnwindSafe},
|
||||
};
|
||||
|
||||
use ahash::AHasher;
|
||||
use static_assertions::assert_impl_all;
|
||||
|
||||
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]
|
||||
fn test_partial_eq() {
|
||||
let s: ByteString = ByteString::from_static("test");
|
||||
|
Loading…
Reference in New Issue
Block a user