From 393cf1ab25b8f206d3bafa7ac3ebb0e480ee008f Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 7 Dec 2019 10:48:22 +0600 Subject: [PATCH] add unsafe from_bytes_unchecked --- string/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/string/src/lib.rs b/string/src/lib.rs index df7949a9..a458f294 100644 --- a/string/src/lib.rs +++ b/string/src/lib.rs @@ -30,6 +30,11 @@ impl ByteString { pub fn from_static(src: &'static str) -> ByteString { Self(Bytes::from_static(src.as_ref())) } + + /// Creates a new `ByteString` from a Bytes. + pub unsafe fn from_bytes_unchecked(src: Bytes) -> ByteString { + Self(src) + } } impl PartialEq for ByteString {