Skip to content

Commit 7203d9a

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 d16538e commit 7203d9a

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/ascii_char.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ 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+
#[allow(clippy::doc_markdown)]
17+
/// [Start of TeXt](http://en.wikipedia.org/wiki/Start_of_Text)
18+
#[doc(hidden)]
19+
#[deprecated(since="1.2.0", note="Replaced with AsciiChar::STX which is the correct name for this variant.")]
1720
SOX = 2,
1821
/// [End of TeXt](http://en.wikipedia.org/wiki/End-of-Text_character)
1922
ETX = 3,
@@ -278,6 +281,13 @@ pub enum AsciiChar {
278281
}
279282

280283
impl AsciiChar {
284+
/// [Start of TeXt](http://en.wikipedia.org/wiki/Start_of_Text)
285+
///
286+
/// (It's an associated constant instead of a variant because
287+
/// the variant for it has an incorrect name.)
288+
#[allow(deprecated, clippy::doc_markdown)]
289+
pub const STX: AsciiChar = AsciiChar::SOX;
290+
281291
/// Constructs an ASCII character from a `u8`, `char` or other character type.
282292
///
283293
/// # Errors
@@ -337,7 +347,7 @@ impl AsciiChar {
337347

338348
#[rustfmt::skip]
339349
const ALL: [AsciiChar; 128] = [
340-
Null, SOH, SOX, ETX, EOT, ENQ, ACK, Bell,
350+
Null, SOH, AsciiChar::STX, ETX, EOT, ENQ, ACK, Bell,
341351
BackSpace, Tab, LineFeed, VT, FF, CarriageReturn, SI, SO,
342352
DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB,
343353
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)