Skip to content

Replace AsciiChar::SOX with associated constant STX` #92

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

Merged
merged 1 commit into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions src/ascii_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ pub enum AsciiChar {
Null = 0,
/// [Start Of Heading](http://en.wikipedia.org/wiki/Start_of_Heading)
SOH = 1,
/// [Start Of teXt](http://en.wikipedia.org/wiki/Start_of_Text)
#[allow(clippy::doc_markdown)]
/// [Start of TeXt](http://en.wikipedia.org/wiki/Start_of_Text)
#[doc(hidden)]
#[deprecated(since="1.2.0", note="Replaced with AsciiChar::STX which is the correct name for this variant.")]
SOX = 2,
/// [End of TeXt](http://en.wikipedia.org/wiki/End-of-Text_character)
ETX = 3,
Expand Down Expand Up @@ -278,6 +281,13 @@ pub enum AsciiChar {
}

impl AsciiChar {
/// [Start of TeXt](http://en.wikipedia.org/wiki/Start_of_Text)
///
/// (It's an associated constant instead of a variant because
/// the variant for it has an incorrect name.)
#[allow(deprecated, clippy::doc_markdown)]
pub const STX: AsciiChar = AsciiChar::SOX;

/// Constructs an ASCII character from a `u8`, `char` or other character type.
///
/// # Errors
Expand Down Expand Up @@ -337,7 +347,7 @@ impl AsciiChar {

#[rustfmt::skip]
const ALL: [AsciiChar; 128] = [
Null, SOH, SOX, ETX, EOT, ENQ, ACK, Bell,
Null, SOH, AsciiChar::STX, ETX, EOT, ENQ, ACK, Bell,
BackSpace, Tab, LineFeed, VT, FF, CarriageReturn, SI, SO,
DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB,
CAN, EM, SUB, ESC, FS, GS, RS, US,
Expand Down
7 changes: 7 additions & 0 deletions tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ fn to_ascii() {
assert_eq!("( ;".as_ascii_str(), Ok(a));
}

#[test]
fn deprecated_variant() {
#![allow(deprecated)]
use AsciiChar::*;
assert_eq!(AsciiChar::STX, SOX);
}

#[test]
#[cfg(feature = "std")]
fn into_ascii() {
Expand Down