summaryrefslogtreecommitdiffstats
path: root/vendor/bstr/src/escape_bytes.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/bstr/src/escape_bytes.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/bstr/src/escape_bytes.rs')
-rw-r--r--vendor/bstr/src/escape_bytes.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/vendor/bstr/src/escape_bytes.rs b/vendor/bstr/src/escape_bytes.rs
index 62c1fcdda..b6775055c 100644
--- a/vendor/bstr/src/escape_bytes.rs
+++ b/vendor/bstr/src/escape_bytes.rs
@@ -129,11 +129,13 @@ enum EscapeState {
/// expose this for core-only use cases too. I'm just not quite sure what the
/// API should be.
#[derive(Clone, Debug)]
+#[cfg(feature = "alloc")]
pub(crate) struct UnescapeBytes<I> {
it: I,
state: UnescapeState,
}
+#[cfg(feature = "alloc")]
impl<I: Iterator<Item = char>> UnescapeBytes<I> {
pub(crate) fn new<T: IntoIterator<IntoIter = I>>(
t: T,
@@ -142,6 +144,7 @@ impl<I: Iterator<Item = char>> UnescapeBytes<I> {
}
}
+#[cfg(feature = "alloc")]
impl<I: Iterator<Item = char>> Iterator for UnescapeBytes<I> {
type Item = u8;
@@ -265,6 +268,7 @@ impl<I: Iterator<Item = char>> Iterator for UnescapeBytes<I> {
/// The state used by the FSM in the unescaping iterator.
#[derive(Clone, Debug)]
+#[cfg(feature = "alloc")]
enum UnescapeState {
/// The start state. Look for an escape sequence, otherwise emit the next
/// codepoint as-is.
@@ -283,6 +287,7 @@ enum UnescapeState {
HexSecond(char),
}
+#[cfg(feature = "alloc")]
impl UnescapeState {
/// Create a new `Bytes` variant with the given slice.
///
@@ -337,6 +342,7 @@ impl UnescapeState {
/// # Panics
///
/// This panics if `ch` is not in `[0-9A-Fa-f]`.
+#[cfg(feature = "alloc")]
fn char_to_hexdigit(ch: char) -> u8 {
u8::try_from(ch.to_digit(16).unwrap()).unwrap()
}