Skip to content

Commit 279d8d5

Browse files
committed
Deprecate byte patterns
1 parent 65d54c1 commit 279d8d5

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ getrandom = "0.2"
2929
[features]
3030
default = ["memchr", "raw_os_str"]
3131

32+
deprecated-byte-patterns = []
3233
raw_os_str = []

src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
//!
7878
//! ### Optional Features
7979
//!
80+
//! - **deprecated-byte-patterns** -
81+
//! Provides an implementation of [`Pattern`] for [`u8`] that panics when it
82+
//! is not an ASCII character. *This feature is deprecated and was only added
83+
//! to ease removal of this pattern type.*
84+
//!
8085
//! - **print\_bytes** -
8186
//! Provides implementations of [`print_bytes::ToBytes`] for [`RawOsStr`] and
8287
//! [`RawOsString`].
@@ -428,5 +433,6 @@ mod private {
428433
impl Sealed for PathBuf {}
429434
impl Sealed for &str {}
430435
impl Sealed for &String {}
436+
#[cfg(feature = "deprecated-byte-patterns")]
431437
impl Sealed for u8 {}
432438
}

src/pattern.rs

+7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ pub trait Encoded {
44
fn __get(&self) -> &[u8];
55
}
66

7+
#[cfg(feature = "deprecated-byte-patterns")]
78
#[derive(Clone)]
89
pub struct EncodedByte([u8; 1]);
910

11+
#[cfg(feature = "deprecated-byte-patterns")]
1012
impl Encoded for EncodedByte {
1113
#[inline]
1214
fn __get(&self) -> &[u8] {
@@ -86,6 +88,11 @@ impl<'a> Pattern for &'a String {
8688
}
8789
}
8890

91+
#[cfg(feature = "deprecated-byte-patterns")]
92+
#[cfg_attr(
93+
os_str_bytes_docs_rs,
94+
doc(cfg(feature = "deprecated-byte-patterns"))
95+
)]
8996
impl Pattern for u8 {
9097
#[doc(hidden)]
9198
type __Encoded = EncodedByte;

0 commit comments

Comments
 (0)