Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added inline and must_use attributes to methods #9

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl<E: Encoding, const N: usize> OrdPath<E, N> {
/// maximum supported length.
///
/// See also [try_from_bytes] which will return an [Error] rather than panicking.
#[inline]
pub fn from_bytes(s: &[u8], enc: E) -> Self {
Self::try_from_bytes(s, enc).unwrap()
}
Expand Down Expand Up @@ -162,6 +163,7 @@ impl<E: Encoding, const N: usize> OrdPath<E, N> {

/// Returns `true` if `self` is empty.
#[inline]
#[must_use]
pub fn is_empty(&self) -> bool {
self.raw.len() == 0
}
Expand All @@ -178,6 +180,7 @@ impl<E: Encoding, const N: usize> OrdPath<E, N> {
/// ```
//
/// See also [is_descendant_of].
#[inline]
pub fn is_ancestor_of(&self, other: &Self) -> bool {
self.encoding().eq(other.encoding()) && self.raw.is_ancestor(&other.raw)
}
Expand All @@ -194,6 +197,7 @@ impl<E: Encoding, const N: usize> OrdPath<E, N> {
/// ```
///
/// See also [is_ancestor_of].
#[inline]
pub fn is_descendant_of(&self, other: &Self) -> bool {
other.is_ancestor_of(self)
}
Expand Down Expand Up @@ -356,6 +360,7 @@ impl<'a, E: Encoding, const N: usize> IntoIterator for &'a OrdPath<E, N> {
type Item = i64;
type IntoIter = Ordinals<&'a [u8], &'a E>;

#[inline]
fn into_iter(self) -> Self::IntoIter {
self.ordinals()
}
Expand All @@ -364,6 +369,7 @@ impl<'a, E: Encoding, const N: usize> IntoIterator for &'a OrdPath<E, N> {
impl<E: Encoding + Default, const N: usize> FromStr for OrdPath<E, N> {
type Err = Error;

#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::try_from_str(s, Default::default())
}
Expand Down
Loading