Deprecate Position::new_const.

This commit is contained in:
Stephen Chung
2022-02-24 09:08:10 +08:00
parent 7263896776
commit 2f5ce2fe5b
2 changed files with 26 additions and 22 deletions

View File

@@ -94,7 +94,7 @@ impl Position {
/// Panics if `line` is zero.
#[inline(always)]
#[must_use]
pub fn new(line: u16, position: u16) -> Self {
pub const fn new(line: u16, position: u16) -> Self {
assert!(line != 0, "line cannot be zero");
let _pos = position;
@@ -106,26 +106,6 @@ impl Position {
pos: _pos,
}
}
/// Create a new [`Position`].
///
/// If `line` is zero, then [`None`] is returned.
///
/// If `position` is zero, then it is at the beginning of a line.
#[inline]
#[must_use]
pub const fn new_const(line: u16, position: u16) -> Option<Self> {
if line == 0 {
return None;
}
let _pos = position;
Some(Self {
#[cfg(not(feature = "no_position"))]
line,
#[cfg(not(feature = "no_position"))]
pos: _pos,
})
}
/// Get the line number (1-based), or [`None`] if there is no position.
#[inline]
#[must_use]