mirror of
https://github.com/tokio-rs/axum.git
synced 2025-09-28 13:30:39 +00:00
Replace unsafe with unwrap (#20)
This commit is contained in:
parent
8a82fd00aa
commit
4fc3d8b5ba
@ -602,7 +602,7 @@
|
|||||||
clippy::match_like_matches_macro,
|
clippy::match_like_matches_macro,
|
||||||
clippy::type_complexity
|
clippy::type_complexity
|
||||||
)]
|
)]
|
||||||
#![deny(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![cfg_attr(test, allow(clippy::float_cmp))]
|
#![cfg_attr(test, allow(clippy::float_cmp))]
|
||||||
|
|
||||||
|
@ -12,10 +12,9 @@ impl ByteStr {
|
|||||||
Self(Bytes::copy_from_slice(s.as_ref().as_bytes()))
|
Self(Bytes::copy_from_slice(s.as_ref().as_bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
pub(crate) fn as_str(&self) -> &str {
|
pub(crate) fn as_str(&self) -> &str {
|
||||||
// SAFETY: `ByteStr` can only be constructed from strings which are
|
// `ByteStr` can only be constructed from strings which are always valid
|
||||||
// always valid utf-8.
|
// utf-8 so this wont panic.
|
||||||
unsafe { std::str::from_utf8_unchecked(&self.0) }
|
std::str::from_utf8(&self.0).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user