mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 19:12:56 +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"]
|
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 }
|
|
||||||
|
@ -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");
|
||||||
|
Loading…
Reference in New Issue
Block a user