Skip to content

Commit f76f527

Browse files
committed
Replace AsciiChar::SOX with associated constant STX
SOX is the wrong name. for this character. Renaming the variant and adding SOX as associated constant would break `use`s of it. both explicit and glob imports. Fixes #78.
1 parent 6a3845a commit f76f527

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/ascii_char.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ pub enum AsciiChar {
1313
Null = 0,
1414
/// [Start Of Heading](http://en.wikipedia.org/wiki/Start_of_Heading)
1515
SOH = 1,
16-
/// [Start Of teXt](http://en.wikipedia.org/wiki/Start_of_Text)
16+
/// [Start of TeXt](http://en.wikipedia.org/wiki/Start_of_Text)
17+
#[doc(hidden)]
18+
#[deprecated(since="1.1.0", note="Replaced with AsciiChar::STX which is the correct name for this variant.")]
1719
SOX = 2,
1820
/// [End of TeXt](http://en.wikipedia.org/wiki/End-of-Text_character)
1921
ETX = 3,
@@ -278,6 +280,13 @@ pub enum AsciiChar {
278280
}
279281

280282
impl AsciiChar {
283+
/// [Start of TeXt](http://en.wikipedia.org/wiki/Start_of_Text)
284+
///
285+
/// (It's an associated constant instead of a variant because
286+
/// it replaces a deprecated variant with incorrect name.)
287+
#[allow(deprecated)]
288+
pub const STX: AsciiChar = AsciiChar::SOX;
289+
281290
/// Constructs an ASCII character from a `u8`, `char` or other character type.
282291
///
283292
/// # Errors
@@ -337,7 +346,7 @@ impl AsciiChar {
337346

338347
#[rustfmt::skip]
339348
const ALL: [AsciiChar; 128] = [
340-
Null, SOH, SOX, ETX, EOT, ENQ, ACK, Bell,
349+
Null, SOH, AsciiChar::STX, ETX, EOT, ENQ, ACK, Bell,
341350
BackSpace, Tab, LineFeed, VT, FF, CarriageReturn, SI, SO,
342351
DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB,
343352
CAN, EM, SUB, ESC, FS, GS, RS, US,

tests.rs

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ fn to_ascii() {
2727
assert_eq!("( ;".as_ascii_str(), Ok(a));
2828
}
2929

30+
#[test]
31+
fn deprecated_variant() {
32+
#![allow(deprecated)]
33+
use AsciiChar::*;
34+
assert_eq!(AsciiChar::STX, SOX);
35+
}
36+
3037
#[test]
3138
#[cfg(feature = "std")]
3239
fn into_ascii() {

0 commit comments

Comments
 (0)