Revise documentation.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
//! Script character position type.
|
||||
#![cfg(not(feature = "no_position"))]
|
||||
|
||||
#[cfg(feature = "no_std")]
|
||||
@@ -48,6 +49,8 @@ impl Position {
|
||||
Self { line, pos: _pos }
|
||||
}
|
||||
/// Get the line number (1-based), or [`None`] if there is no position.
|
||||
///
|
||||
/// Always returns [`None`] under `no_position`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn line(self) -> Option<usize> {
|
||||
@@ -58,6 +61,8 @@ impl Position {
|
||||
}
|
||||
}
|
||||
/// Get the character position (1-based), or [`None`] if at beginning of a line.
|
||||
///
|
||||
/// Always returns [`None`] under `no_position`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn position(self) -> Option<usize> {
|
||||
@@ -100,18 +105,24 @@ impl Position {
|
||||
}
|
||||
}
|
||||
/// Is this [`Position`] at the beginning of a line?
|
||||
///
|
||||
/// Always returns `false` under `no_position`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn is_beginning_of_line(self) -> bool {
|
||||
self.pos == 0 && !self.is_none()
|
||||
}
|
||||
/// Is there no [`Position`]?
|
||||
///
|
||||
/// Always returns `true` under `no_position`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn is_none(self) -> bool {
|
||||
self.line == 0 && self.pos == 0
|
||||
}
|
||||
/// Returns an fallback [`Position`] if it is [`NONE`][Position::NONE]?
|
||||
///
|
||||
/// Always returns the fallback under `no_position`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn or_else(self, pos: Self) -> Self {
|
||||
@@ -219,18 +230,24 @@ impl Span {
|
||||
Self { start, end }
|
||||
}
|
||||
/// Is this [`Span`] non-existent?
|
||||
///
|
||||
/// Always returns `true` under `no_position`.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn is_none(&self) -> bool {
|
||||
self.start.is_none() && self.end.is_none()
|
||||
}
|
||||
/// Get the [`Span`]'s starting [position][Position].
|
||||
///
|
||||
/// Always returns [`Position::NONE`] under `no_position`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn start(&self) -> Position {
|
||||
self.start
|
||||
}
|
||||
/// Get the [`Span`]'s ending [position][Position].
|
||||
///
|
||||
/// Always returns [`Position::NONE`] under `no_position`.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn end(&self) -> Position {
|
||||
|
Reference in New Issue
Block a user