Skip to content

Commit

Permalink
[new_name/label] Add 'WILDCARD' and 'is_wildcard()'
Browse files Browse the repository at this point in the history
  • Loading branch information
bal-e committed Oct 28, 2024
1 parent 2ca8a33 commit 6614676
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/base/new_name/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ impl Label {
pub const MAX_SIZE: usize = 63;

/// The root label.
pub const ROOT: &Self = unsafe { Self::from_bytes_unchecked(&[]) };
pub const ROOT: &Self = unsafe { Self::from_bytes_unchecked(b"") };

Check failure on line 18 in src/base/new_name/label.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 1.76.0)

`&` without an explicit lifetime name cannot be used here

Check failure on line 18 in src/base/new_name/label.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 1.76.0)

`&` without an explicit lifetime name cannot be used here

Check failure on line 18 in src/base/new_name/label.rs

View workflow job for this annotation

GitHub Actions / test (macOS-latest, 1.76.0)

`&` without an explicit lifetime name cannot be used here

/// The wildcard label.
pub const WILDCARD: &Self = unsafe { Self::from_bytes_unchecked(b"*") };

Check failure on line 21 in src/base/new_name/label.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 1.76.0)

`&` without an explicit lifetime name cannot be used here

Check failure on line 21 in src/base/new_name/label.rs

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 1.76.0)

`&` without an explicit lifetime name cannot be used here

Check failure on line 21 in src/base/new_name/label.rs

View workflow job for this annotation

GitHub Actions / test (macOS-latest, 1.76.0)

`&` without an explicit lifetime name cannot be used here
}

impl Label {
Expand Down Expand Up @@ -71,6 +74,12 @@ impl Label {
self.0.is_empty()
}

/// Whether this is the wildcard label.
pub const fn is_wildcard(&self) -> bool {
// NOTE: 'self.0 == *b"*"' is not const.
self.0.len() == 1 && self.0[0] == b'*'
}

/// The size of this name in the wire format.
#[allow(clippy::len_without_is_empty)]
pub const fn len(&self) -> usize {
Expand Down

0 comments on commit 6614676

Please sign in to comment.