refactor: replace static_assert! with std assert! (#1112)

This commit is contained in:
Paolo Barbolini
2025-10-01 14:45:08 +02:00
committed by GitHub
parent 55cea7dbe6
commit b73611c67f

View File

@@ -186,21 +186,15 @@ impl HeaderName {
/// Creates a new header name, panics on invalid name /// Creates a new header name, panics on invalid name
pub const fn new_from_ascii_str(ascii: &'static str) -> Self { pub const fn new_from_ascii_str(ascii: &'static str) -> Self {
macro_rules! static_assert { assert!(!ascii.is_empty());
($condition:expr) => { assert!(ascii.len() <= 76);
let _ = [()][(!($condition)) as usize]; assert!(ascii.is_ascii());
};
}
static_assert!(!ascii.is_empty());
static_assert!(ascii.len() <= 76);
let bytes = ascii.as_bytes(); let bytes = ascii.as_bytes();
let mut i = 0; let mut i = 0;
while i < bytes.len() { while i < bytes.len() {
static_assert!(bytes[i].is_ascii()); assert!(bytes[i] != b' ');
static_assert!(bytes[i] != b' '); assert!(bytes[i] != b':');
static_assert!(bytes[i] != b':');
i += 1; i += 1;
} }