Skip to content

Commit a834fc3

Browse files
committed
Switch back to short-circuiting || and && operators in const fn
Enabled by Rust 1.46 as part of const if/else I assume.
1 parent dffb741 commit a834fc3

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
rust: [1.41.1, stable, beta, nightly]
16+
rust: [1.44.1, stable, beta, nightly]
1717
steps:
1818
- uses: actions/checkout@v2
1919
- uses: hecrj/setup-rust-action@v1

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ ascii = { version = "1.0", default-features = false, features = ["alloc"] }
3535

3636
## Minimum supported Rust version
3737

38-
The minimum Rust version for 1.0.\* releases is 1.33.0.
38+
The minimum Rust version for 1.1.\* releases is 1.44.0.
3939
Later 1.y.0 releases might require newer Rust versions, but the three most
4040
recent stable releases at the time of publishing will always be supported.
41-
For example this means that if the current stable Rust version is 1.38 when
42-
ascii 1.1.0 is released, then ascii 1.1.\* will not require a newer
43-
Rust version than 1.36.
41+
For example this means that if the current stable Rust version is 1.50 when
42+
ascii 1.2.0 is released, then ascii 1.2.\* will not require a newer
43+
Rust version than 1.48.
4444

4545
## History
4646

src/ascii_char.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl AsciiChar {
411411
#[inline]
412412
#[must_use]
413413
pub const fn is_alphabetic(self) -> bool {
414-
(self.to_not_upper() >= b'a') & (self.to_not_upper() <= b'z')
414+
(self.to_not_upper() >= b'a') && (self.to_not_upper() <= b'z')
415415
}
416416

417417
/// Check if the character is a letter (a-z, A-Z).
@@ -457,14 +457,14 @@ impl AsciiChar {
457457
#[inline]
458458
#[must_use]
459459
pub const fn is_ascii_digit(&self) -> bool {
460-
(*self as u8 >= b'0') & (*self as u8 <= b'9')
460+
(*self as u8 >= b'0') && (*self as u8 <= b'9')
461461
}
462462

463463
/// Check if the character is a letter or number
464464
#[inline]
465465
#[must_use]
466466
pub const fn is_alphanumeric(self) -> bool {
467-
self.is_alphabetic() | self.is_ascii_digit()
467+
self.is_alphabetic() || self.is_ascii_digit()
468468
}
469469

470470
/// Check if the character is a letter or number
@@ -491,7 +491,7 @@ impl AsciiChar {
491491
#[inline]
492492
#[must_use]
493493
pub const fn is_ascii_blank(&self) -> bool {
494-
(*self as u8 == b' ') | (*self as u8 == b'\t')
494+
(*self as u8 == b' ') || (*self as u8 == b'\t')
495495
}
496496

497497
/// Check if the character one of ' ', '\t', '\n', '\r',
@@ -500,7 +500,7 @@ impl AsciiChar {
500500
#[must_use]
501501
pub const fn is_whitespace(self) -> bool {
502502
let b = self as u8;
503-
self.is_ascii_blank() | (b == b'\n') | (b == b'\r') | (b == 0x0b) | (b == 0x0c)
503+
self.is_ascii_blank() || (b == b'\n') || (b == b'\r') || (b == 0x0b) || (b == 0x0c)
504504
}
505505

506506
/// Check if the character is a ' ', '\t', '\n', '\r' or '\0xc' (form feed).
@@ -510,9 +510,9 @@ impl AsciiChar {
510510
#[must_use]
511511
pub const fn is_ascii_whitespace(&self) -> bool {
512512
self.is_ascii_blank()
513-
| (*self as u8 == b'\n')
514-
| (*self as u8 == b'\r')
515-
| (*self as u8 == 0x0c/*form feed*/)
513+
|| (*self as u8 == b'\n')
514+
|| (*self as u8 == b'\r')
515+
|| (*self as u8 == 0x0c/*form feed*/)
516516
}
517517

518518
/// Check if the character is a control character
@@ -530,7 +530,7 @@ impl AsciiChar {
530530
#[inline]
531531
#[must_use]
532532
pub const fn is_ascii_control(&self) -> bool {
533-
((*self as u8) < b' ') | (*self as u8 == 127)
533+
((*self as u8) < b' ') || (*self as u8 == 127)
534534
}
535535

536536
/// Checks if the character is printable (except space)
@@ -624,7 +624,7 @@ impl AsciiChar {
624624
#[inline]
625625
#[must_use]
626626
pub const fn is_ascii_punctuation(&self) -> bool {
627-
self.is_ascii_graphic() & !self.is_alphanumeric()
627+
self.is_ascii_graphic() && !self.is_alphanumeric()
628628
}
629629

630630
/// Checks if the character is a valid hex digit
@@ -641,7 +641,7 @@ impl AsciiChar {
641641
#[inline]
642642
#[must_use]
643643
pub const fn is_ascii_hexdigit(&self) -> bool {
644-
self.is_ascii_digit() | ((*self as u8 | 0x20_u8).wrapping_sub(b'a') < 6)
644+
self.is_ascii_digit() || ((*self as u8 | 0x20u8).wrapping_sub(b'a') < 6)
645645
}
646646

647647
/// Unicode has printable versions of the ASCII control codes, like '␛'.
@@ -728,7 +728,7 @@ impl AsciiChar {
728728
#[must_use]
729729
pub const fn eq_ignore_ascii_case(&self, other: &Self) -> bool {
730730
(self.as_byte() == other.as_byte())
731-
| (self.is_alphabetic() & (self.to_not_upper() == other.to_not_upper()))
731+
|| (self.is_alphabetic() && (self.to_not_upper() == other.to_not_upper()))
732732
}
733733
}
734734

src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
//!
1616
//! # Minimum supported Rust version
1717
//!
18-
//! The minimum Rust version for 1.0.\* releases is 1.33.0.
18+
//! The minimum Rust version for 1.1.\* releases is 1.44.0.
1919
//! Later 1.y.0 releases might require newer Rust versions, but the three most
2020
//! recent stable releases at the time of publishing will always be supported.
21-
//! For example this means that if the current stable Rust version is 1.38 when
22-
//! ascii 1.1.0 is released, then ascii 1.1.* will not require a newer
23-
//! Rust version than 1.36.
21+
//! For example this means that if the current stable Rust version is 1.50 when
22+
//! ascii 1.2.0 is released, then ascii 1.2.* will not require a newer
23+
//! Rust version than 1.48.
2424
//!
2525
//! # History
2626
//!

0 commit comments

Comments
 (0)