pub struct UndefinedVariableError { /* private fields */ }Expand description
A variable the context does not bind, reported as an error rather than as undefined.
use predicator_rs::UndefinedVariableError;
let error = UndefinedVariableError::new("unbound_variable", "x is not bound");
assert_eq!(error.reason(), "unbound_variable");Implementations§
Source§impl UndefinedVariableError
impl UndefinedVariableError
Sourcepub fn new(reason: impl Into<String>, message: impl Into<String>) -> Self
pub fn new(reason: impl Into<String>, message: impl Into<String>) -> Self
An error with a reason (the corpus’s token) and a message (a sentence for a person), at no position.
use predicator_rs::{UndefinedVariableError, Position};
let error = UndefinedVariableError::new("some_reason", "a sentence");
assert_eq!(error.reason(), "some_reason");
assert_eq!(error.position(), None);Sourcepub fn with_position(self, position: Position) -> Self
pub fn with_position(self, position: Position) -> Self
The same error at position.
use predicator_rs::{UndefinedVariableError, Position};
let error = UndefinedVariableError::new("some_reason", "a sentence");
let at = Position { line: 2, column: 3 };
assert_eq!(error.with_position(at).position(), Some(at));Sourcepub fn reason(&self) -> &str
pub fn reason(&self) -> &str
The reason: the structured token the corpus names, which is normative.
use predicator_rs::{UndefinedVariableError, Position};
let error = UndefinedVariableError::new("some_reason", "a sentence");
assert_eq!(error.reason(), "some_reason");Sourcepub fn message(&self) -> &str
pub fn message(&self) -> &str
The message: a sentence for a person, which is not normative.
use predicator_rs::{UndefinedVariableError, Position};
let error = UndefinedVariableError::new("some_reason", "a sentence");
assert_eq!(error.message(), "a sentence");
assert_eq!(error.to_string(), "a sentence");Sourcepub fn position(&self) -> Option<Position>
pub fn position(&self) -> Option<Position>
Where in the source the failure is, when that is known.
use predicator_rs::{UndefinedVariableError, Position};
let error = UndefinedVariableError::new("some_reason", "a sentence");
assert_eq!(error.position(), None);
let at = Position { line: 1, column: 1 };
assert_eq!(error.with_position(at).position(), Some(at));Trait Implementations§
Source§impl Clone for UndefinedVariableError
impl Clone for UndefinedVariableError
Source§impl Debug for UndefinedVariableError
impl Debug for UndefinedVariableError
Source§impl Display for UndefinedVariableError
impl Display for UndefinedVariableError
impl Eq for UndefinedVariableError
Source§impl Error for UndefinedVariableError
impl Error for UndefinedVariableError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<UndefinedVariableError> for Error
impl From<UndefinedVariableError> for Error
Source§fn from(error: UndefinedVariableError) -> Error
fn from(error: UndefinedVariableError) -> Error
Converts to this type from the input type.
Source§impl PartialEq for UndefinedVariableError
impl PartialEq for UndefinedVariableError
impl StructuralPartialEq for UndefinedVariableError
Auto Trait Implementations§
impl Forget for UndefinedVariableError
impl Freeze for UndefinedVariableError
impl Move for UndefinedVariableError
impl RefUnwindSafe for UndefinedVariableError
impl Send for UndefinedVariableError
impl Sync for UndefinedVariableError
impl Unpin for UndefinedVariableError
impl UnsafeUnpin for UndefinedVariableError
impl UnwindSafe for UndefinedVariableError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more