pub struct InspectPath { /* private fields */ }Expand description
A path through an inspected value tree.
Paths represent navigation from a root value to a specific nested value, using field names and indices.
§Examples
use inspect_core::{InspectPath, PathSegment};
let path = InspectPath::new()
.field("users")
.index(2)
.field("name");
assert_eq!(path.to_string(), "users[2].name");Implementations§
Source§impl InspectPath
impl InspectPath
Sourcepub fn new() -> InspectPath
pub fn new() -> InspectPath
Create a new empty path.
Sourcepub fn field(self, name: impl Into<String>) -> InspectPath
pub fn field(self, name: impl Into<String>) -> InspectPath
Append a field access to this path.
Sourcepub fn index(self, idx: usize) -> InspectPath
pub fn index(self, idx: usize) -> InspectPath
Append an index access to this path.
Sourcepub fn segments(&self) -> &[PathSegment]
pub fn segments(&self) -> &[PathSegment]
Get the segments in this path.
Trait Implementations§
Source§impl Clone for InspectPath
impl Clone for InspectPath
Source§fn clone(&self) -> InspectPath
fn clone(&self) -> InspectPath
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 InspectPath
impl Debug for InspectPath
Source§impl Default for InspectPath
impl Default for InspectPath
Source§fn default() -> InspectPath
fn default() -> InspectPath
Returns the “default value” for a type. Read more
Source§impl Display for InspectPath
impl Display for InspectPath
impl Eq for InspectPath
Source§impl PartialEq for InspectPath
impl PartialEq for InspectPath
impl StructuralPartialEq for InspectPath
Auto Trait Implementations§
impl Freeze for InspectPath
impl RefUnwindSafe for InspectPath
impl Send for InspectPath
impl Sync for InspectPath
impl Unpin for InspectPath
impl UnsafeUnpin for InspectPath
impl UnwindSafe for InspectPath
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