pub enum Structural {
Closing(BracketType, usize),
Colon(usize),
Opening(BracketType, usize),
Comma(usize),
}
Expand description
Defines structural characters in JSON documents.
Variants§
Closing(BracketType, usize)
Represents the closing square or curly brace, ‘]’ or ‘}’.
Colon(usize)
Represents the colon ‘:’ character.
Opening(BracketType, usize)
Represents the opening square or curly brace, ‘[’ or ‘{’.
Comma(usize)
Represents the comma ‘,’ character.
Implementations§
Source§impl Structural
impl Structural
Sourcepub fn idx(self) -> usize
pub fn idx(self) -> usize
Returns the index of the character in the document, i.e. which byte it is counting from 0.
Sourcepub fn offset(self, amount: usize) -> Self
pub fn offset(self, amount: usize) -> Self
Add a given amount to the structural’s index.
§Examples
let structural = Structural::Colon(42);
let offset_structural = structural.offset(10);
assert_eq!(structural.idx(), 42);
assert_eq!(offset_structural.idx(), 52);
Sourcepub fn is_closing(&self) -> bool
pub fn is_closing(&self) -> bool
Check if the structural represents a closing character,
i.e. a Closing
with either of the BracketType
variants.
§Examples
let brace = Structural::Closing(BracketType::Curly, 42);
let bracket = Structural::Closing(BracketType::Square, 43);
let neither = Structural::Comma(44);
assert!(brace.is_closing());
assert!(bracket.is_closing());
assert!(!neither.is_closing());
Sourcepub fn is_opening(&self) -> bool
pub fn is_opening(&self) -> bool
Check if the structural represents an opening character,
i.e. an Opening
with either of the BracketType
variants.
§Examples
let brace = Structural::Opening(BracketType::Curly, 42);
let bracket = Structural::Opening(BracketType::Square, 43);
let neither = Structural::Comma(44);
assert!(brace.is_opening());
assert!(bracket.is_opening());
assert!(!neither.is_opening());
Trait Implementations§
Source§impl Clone for Structural
impl Clone for Structural
Source§fn clone(&self) -> Structural
fn clone(&self) -> Structural
Returns a duplicate 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 Structural
impl Debug for Structural
Source§impl Hash for Structural
impl Hash for Structural
Source§impl PartialEq for Structural
impl PartialEq for Structural
impl Copy for Structural
impl Eq for Structural
impl StructuralPartialEq for Structural
Auto Trait Implementations§
impl Freeze for Structural
impl RefUnwindSafe for Structural
impl Send for Structural
impl Sync for Structural
impl Unpin for Structural
impl UnwindSafe for Structural
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