mirror of https://github.com/fafhrd91/actix-net
Add `Safety` section to `ByteString::from_bytes_unchecked`
This commit is contained in:
parent
c14808e656
commit
bf4c069624
|
@ -33,6 +33,13 @@ impl ByteString {
|
|||
}
|
||||
|
||||
/// Creates a new `ByteString` from a Bytes.
|
||||
///
|
||||
/// # Safety
|
||||
/// This function is unsafe because it does not check the bytes passed to it
|
||||
/// are valid UTF-8. If this constraint is violated,
|
||||
/// it may cause memory unsafety issues with future users of the `ByteString`,
|
||||
/// as we assume that `ByteString`s are valid UTF-8.
|
||||
/// However, the most likely issue is that the data gets corrupted.
|
||||
pub const unsafe fn from_bytes_unchecked(src: Bytes) -> ByteString {
|
||||
Self(src)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue