Skip to content

Commit 697d5e3

Browse files
committed
Constify methods that "dereference" raw pointers
* AsciiStr::as_str() * AsciiStr::as_bytes()
1 parent 1115033 commit 697d5e3

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

.github/workflows/ci.yml

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ascii = { version = "1.0", default-features = false, features = ["alloc"] }
3535

3636
## Minimum supported Rust version
3737

38-
The minimum Rust version for 1.1.\* releases is 1.57.0.
38+
The minimum Rust version for 1.1.\* releases is 1.58.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.
4141
For example this means that if the current stable Rust version is 1.70 when

src/ascii_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ impl AsciiStr {
4848
/// Converts `&self` to a `&str` slice.
4949
#[inline]
5050
#[must_use]
51-
pub fn as_str(&self) -> &str {
51+
pub const fn as_str(&self) -> &str {
5252
// SAFETY: All variants of `AsciiChar` are valid bytes for a `str`.
5353
unsafe { &*(self as *const AsciiStr as *const str) }
5454
}
5555

5656
/// Converts `&self` into a byte slice.
5757
#[inline]
5858
#[must_use]
59-
pub fn as_bytes(&self) -> &[u8] {
59+
pub const fn as_bytes(&self) -> &[u8] {
6060
// SAFETY: All variants of `AsciiChar` are valid `u8`, given they're `repr(u8)`.
6161
unsafe { &*(self as *const AsciiStr as *const [u8]) }
6262
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//!
1616
//! # Minimum supported Rust version
1717
//!
18-
//! The minimum Rust version for 1.1.\* releases is 1.57.0.
18+
//! The minimum Rust version for 1.1.\* releases is 1.58.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.
2121
//! For example this means that if the current stable Rust version is 1.70 when

0 commit comments

Comments
 (0)