pub struct SmilesErrorWithSpan { /* private fields */ }Expand description
Wraps the Smiles error adding the location of where the error was found
Implementations§
Source§impl SmilesErrorWithSpan
impl SmilesErrorWithSpan
Sourcepub fn new(smiles_error: SmilesError, start: usize, end: usize) -> Self
pub fn new(smiles_error: SmilesError, start: usize, end: usize) -> Self
Creates a new error from the SmilesError and the span
§Examples
use smiles_rs::{SmilesError, SmilesErrorWithSpan};
let err = SmilesErrorWithSpan::new(SmilesError::UnexpectedEndOfString, 2, 3);
assert_eq!(err.start(), 2);
assert_eq!(err.end(), 3);Sourcepub fn smiles_error(&self) -> SmilesError
pub fn smiles_error(&self) -> SmilesError
Returns the SmilesError
§Examples
use smiles_rs::{SmilesError, SmilesErrorWithSpan};
let err = SmilesErrorWithSpan::new(SmilesError::InvalidNumber, 0, 1);
assert_eq!(err.smiles_error(), SmilesError::InvalidNumber);Sourcepub fn start(&self) -> usize
pub fn start(&self) -> usize
Returns the start of the span
§Examples
use smiles_rs::{SmilesError, SmilesErrorWithSpan};
let err = SmilesErrorWithSpan::new(SmilesError::InvalidClass, 4, 6);
assert_eq!(err.start(), 4);Sourcepub fn end(&self) -> usize
pub fn end(&self) -> usize
Returns the end of the span
§Examples
use smiles_rs::{SmilesError, SmilesErrorWithSpan};
let err = SmilesErrorWithSpan::new(SmilesError::InvalidClass, 4, 6);
assert_eq!(err.end(), 6);Sourcepub fn span(&self) -> Range<usize> ⓘ
pub fn span(&self) -> Range<usize> ⓘ
Returns the full span for the error
§Examples
use smiles_rs::{SmilesError, SmilesErrorWithSpan};
let err = SmilesErrorWithSpan::new(SmilesError::UnexpectedLeftBracket, 1, 2);
assert_eq!(err.span(), 1..2);Sourcepub fn render(&self, input: &str) -> String
pub fn render(&self, input: &str) -> String
Render the error pointing back to location in the original string
§Examples
use smiles_rs::{SmilesError, SmilesErrorWithSpan};
let err = SmilesErrorWithSpan::new(SmilesError::UnexpectedRightBracket, 1, 2);
let rendered = err.render("C]");
assert!(rendered.contains("C]"));
assert!(rendered.contains("^"));Trait Implementations§
Source§impl Debug for SmilesErrorWithSpan
impl Debug for SmilesErrorWithSpan
Auto Trait Implementations§
impl Freeze for SmilesErrorWithSpan
impl RefUnwindSafe for SmilesErrorWithSpan
impl Send for SmilesErrorWithSpan
impl Sync for SmilesErrorWithSpan
impl Unpin for SmilesErrorWithSpan
impl UnsafeUnpin for SmilesErrorWithSpan
impl UnwindSafe for SmilesErrorWithSpan
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
Source§impl<T> CliqueRankerExt for T
impl<T> CliqueRankerExt for T
Source§fn then<R>(self, other: R) -> ChainedRanker<Self, R>
fn then<R>(self, other: R) -> ChainedRanker<Self, R>
Chains this ranker with another. The first ranker breaks ties first;
the second ranker is consulted only when the first returns
Equal.