diff options
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | src/ext_slice.rs | 12 | ||||
-rw-r--r-- | src/ext_vec.rs | 10 | ||||
-rw-r--r-- | src/impls.rs | 8 |
8 files changed, 30 insertions, 14 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 78c885d..117fa04 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "86947727666d7b21c97eb16145b3ad6ac22aacd3" + "sha1": "65993b58be1547bfc0de9ad8c1c8f3d3fcb0a32f" }, "path_in_vcs": "" }
\ No newline at end of file @@ -44,7 +44,7 @@ rust_library { host_supported: true, crate_name: "bstr", cargo_env_compat: true, - cargo_pkg_version: "1.1.0", + cargo_pkg_version: "1.2.0", srcs: ["src/lib.rs"], edition: "2021", features: [ @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.60" name = "bstr" -version = "1.1.0" +version = "1.2.0" authors = ["Andrew Gallant <jamslam@gmail.com>"] exclude = ["/.github"] description = "A string type that is not required to be valid UTF-8." diff --git a/Cargo.toml.orig b/Cargo.toml.orig index b08cd68..bdfa0b7 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "bstr" -version = "1.1.0" #:version +version = "1.2.0" #:version authors = ["Andrew Gallant <jamslam@gmail.com>"] description = "A string type that is not required to be valid UTF-8." documentation = "https://docs.rs/bstr" @@ -11,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/bstr/bstr-1.1.0.crate" + value: "https://static.crates.io/crates/bstr/bstr-1.2.0.crate" } - version: "1.1.0" + version: "1.2.0" license_type: NOTICE last_upgrade_date { year: 2023 month: 2 - day: 1 + day: 15 } } diff --git a/src/ext_slice.rs b/src/ext_slice.rs index 70f94e2..91af450 100644 --- a/src/ext_slice.rs +++ b/src/ext_slice.rs @@ -101,12 +101,16 @@ impl<const N: usize> ByteSlice for [u8; N] { /// Ensure that callers cannot implement `ByteSlice` by making an /// umplementable trait its super trait. -pub trait Sealed {} -impl Sealed for [u8] {} -impl<const N: usize> Sealed for [u8; N] {} +mod private { + pub trait Sealed {} +} +impl private::Sealed for [u8] {} +impl<const N: usize> private::Sealed for [u8; N] {} /// A trait that extends `&[u8]` with string oriented methods. -pub trait ByteSlice: Sealed { +/// +/// This trait is sealed and cannot be implemented outside of `bstr`. +pub trait ByteSlice: private::Sealed { /// A method for accessing the raw bytes of this type. This is always a /// no-op and callers shouldn't care about it. This only exists for making /// the extension trait work. diff --git a/src/ext_vec.rs b/src/ext_vec.rs index 5effdd0..b8e2be2 100644 --- a/src/ext_vec.rs +++ b/src/ext_vec.rs @@ -104,8 +104,10 @@ impl ByteVec for Vec<u8> { /// Ensure that callers cannot implement `ByteSlice` by making an /// umplementable trait its super trait. -pub trait Sealed {} -impl Sealed for Vec<u8> {} +mod private { + pub trait Sealed {} +} +impl private::Sealed for Vec<u8> {} /// A trait that extends `Vec<u8>` with string oriented methods. /// @@ -119,7 +121,9 @@ impl Sealed for Vec<u8> {} /// let s = Vec::from_slice(b"abc"); // NOT ByteVec::from_slice("...") /// assert_eq!(s, B("abc")); /// ``` -pub trait ByteVec: Sealed { +/// +/// This trait is sealed and cannot be implemented outside of `bstr`. +pub trait ByteVec: private::Sealed { /// A method for accessing the raw vector bytes of this type. This is /// always a no-op and callers shouldn't care about it. This only exists /// for making the extension trait work. diff --git a/src/impls.rs b/src/impls.rs index eac4700..7ae4510 100644 --- a/src/impls.rs +++ b/src/impls.rs @@ -667,6 +667,14 @@ mod bstr { } } + #[cfg(feature = "alloc")] + impl Clone for Box<BStr> { + #[inline] + fn clone(&self) -> Self { + BStr::from_boxed_bytes(self.as_bytes().into()) + } + } + impl Eq for BStr {} impl PartialEq<BStr> for BStr { |