pub struct ParseContainer { /* private fields */ }
Expand description
An intermediate representation to parse.
The ParseContainer
has a shared pointer of the original String
and the pair of sub-string position (begin
and end
),
Implementations§
Source§impl ParseContainer
impl ParseContainer
Sourcepub fn new(raw: Arc<String>) -> Self
pub fn new(raw: Arc<String>) -> Self
Creates a new ParseContainer
from the original string.
The inner positions are held in the entirety of the original string.
§Examples
let _ = ParseContainer::new(Arc::new("foo".to_string()));
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if self
has a length of zero
§Examples
let container = ParseContainer::from("");
assert!(container.is_empty());
let container = ParseContainer::from("foo");
let (_rest, parsed) = container.split_at(0);
assert!(parsed.is_empty());
let (rest, _parsed) = container.split_at(container.len());
assert!(rest.is_empty());
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of self
§Examples
let container = ParseContainer::from("foo");
assert_eq!(container.len(), 3);
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns a string slice of the sub-string
§Examples
let container = ParseContainer::from("foo");
let s: &str = container.as_str(); // Returns `&str`
assert_eq!(s, "foo");
Trait Implementations§
Source§impl Borrow<str> for ParseContainer
impl Borrow<str> for ParseContainer
Source§impl Clone for ParseContainer
impl Clone for ParseContainer
Source§fn clone(&self) -> ParseContainer
fn clone(&self) -> ParseContainer
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ParseContainer
impl Debug for ParseContainer
Source§impl Display for ParseContainer
impl Display for ParseContainer
Source§impl From<&[ParseContainer]> for ParseContainer
impl From<&[ParseContainer]> for ParseContainer
Source§fn from(x: &[ParseContainer]) -> Self
fn from(x: &[ParseContainer]) -> Self
Converts to this type from the input type.
Source§impl From<&str> for ParseContainer
impl From<&str> for ParseContainer
Source§impl From<String> for ParseContainer
impl From<String> for ParseContainer
Source§impl From<Vec<ParseContainer>> for ParseContainer
impl From<Vec<ParseContainer>> for ParseContainer
Source§fn from(x: Vec<ParseContainer>) -> Self
fn from(x: Vec<ParseContainer>) -> Self
Converts to this type from the input type.
Source§impl InputLength for ParseContainer
impl InputLength for ParseContainer
Source§impl PartialEq<&str> for ParseContainer
impl PartialEq<&str> for ParseContainer
Source§impl PartialEq<ParseContainer> for &str
impl PartialEq<ParseContainer> for &str
Source§impl PartialEq for ParseContainer
impl PartialEq for ParseContainer
Auto Trait Implementations§
impl Freeze for ParseContainer
impl RefUnwindSafe for ParseContainer
impl Send for ParseContainer
impl Sync for ParseContainer
impl Unpin for ParseContainer
impl UnwindSafe for ParseContainer
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