Skip to content

Match CharEscape discriminants to ESCAPE table entries #1279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1514,26 +1514,27 @@ impl<'a, W: io::Write, F: Formatter> ser::Serializer for RawValueStrEmitter<'a,
}

/// Represents a character escape code in a type-safe manner.
#[repr(u8)]
pub enum CharEscape {
/// An escaped quote `"`
Quote,
Quote = b'"',
/// An escaped reverse solidus `\`
ReverseSolidus,
ReverseSolidus = b'\\',
/// An escaped solidus `/`
Solidus,
Solidus = b'/',
/// An escaped backspace character (usually escaped as `\b`)
Backspace,
Backspace = b'b',
/// An escaped form feed character (usually escaped as `\f`)
FormFeed,
FormFeed = b'f',
/// An escaped line feed character (usually escaped as `\n`)
LineFeed,
LineFeed = b'n',
/// An escaped carriage return character (usually escaped as `\r`)
CarriageReturn,
CarriageReturn = b'r',
/// An escaped tab character (usually escaped as `\t`)
Tab,
Tab = b't',
/// An escaped ASCII plane control character (usually escaped as
/// `\u00XX` where `XX` are two hex characters)
AsciiControl(u8),
AsciiControl(u8) = b'u',
}

/// This trait abstracts away serializing the JSON control characters, which allows the user to
Expand Down
Loading