1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-08-20 11:05:37 +02:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Rob Ede
71b4e55c92 prepare bytestring release 1.1.0 (#461) 2022-06-11 13:41:11 +01:00
Marcus Griep
eb5fa30ada feat: impls for Box and String conversions (#458)
Co-authored-by: Rob Ede <robjtede@icloud.com>
2022-06-11 04:22:34 +01:00
3 changed files with 27 additions and 2 deletions

View File

@@ -1,8 +1,15 @@
# Changes
## Unreleased - 2022-xx-xx
## 1.1.0 - 2022-06-11
- Implement `From<Box<str>>` for `ByteString`. [#458]
- Implement `Into<String>` for `ByteString`. [#458]
- Minimum supported Rust version (MSRV) is now 1.49.
[#458]: https://github.com/actix/actix-net/pull/458
## 1.0.0 - 2020-12-31
- Update `bytes` dependency to `1`.

View File

@@ -1,6 +1,6 @@
[package]
name = "bytestring"
version = "1.0.0"
version = "1.1.0"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",

View File

@@ -6,7 +6,11 @@
extern crate alloc;
use alloc::{string::String, vec::Vec};
use alloc::{
boxed::Box,
string::{String, ToString},
vec::Vec,
};
use core::{borrow, convert::TryFrom, fmt, hash, ops, str};
use bytes::Bytes;
@@ -110,6 +114,20 @@ impl From<&str> for ByteString {
}
}
impl From<Box<str>> for ByteString {
#[inline]
fn from(value: Box<str>) -> Self {
Self(Bytes::from(value.into_boxed_bytes()))
}
}
impl From<ByteString> for String {
#[inline]
fn from(value: ByteString) -> Self {
value.to_string()
}
}
impl TryFrom<&[u8]> for ByteString {
type Error = str::Utf8Error;