pub struct ParameterPath { /* private fields */ }Expand description
Path to a Parameter nested inside a Parameterized type instance, composed of ParameterPathSegments.
§Example
let value = vec![(4, 2)];
let paths = value.parameter_paths().map(|path| path.to_string()).collect::<Vec<_>>();
assert_eq!(paths, vec!["$[0].0", "$[0].1"]);Implementations§
Source§impl ParameterPath
impl ParameterPath
Sourcepub fn root() -> Self
pub fn root() -> Self
Creates a new empty (i.e., root) ParameterPath.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of ParameterPathSegments in this ParameterPath.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this ParameterPath contains no ParameterPathSegments (i.e., is the root path).
Sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
Returns true if this ParameterPath is the root path (i.e., is empty).
Sourcepub fn is_prefix_of(&self, other: &Self) -> bool
pub fn is_prefix_of(&self, other: &Self) -> bool
Returns true if this ParameterPath is a prefix of other.
Sourcepub fn segments(
&self,
) -> impl DoubleEndedIterator<Item = &ParameterPathSegment> + '_
pub fn segments( &self, ) -> impl DoubleEndedIterator<Item = &ParameterPathSegment> + '_
Returns an iterator over the ParameterPathSegments in this ParameterPath in root-to-leaf order.
Sourcepub fn with_segment(self, segment: ParameterPathSegment) -> Self
pub fn with_segment(self, segment: ParameterPathSegment) -> Self
Returns a new ParameterPath with the provided ParameterPathSegment appended to it.
§Example
let path = ParameterPath::root()
.field("weights")
.index(1)
.tuple_index(0);
assert_eq!(path.to_string(), "$.weights[1].0");Sourcepub fn field(self, name: &'static str) -> Self
pub fn field(self, name: &'static str) -> Self
Returns a new ParameterPath with a ParameterPathSegment::Field segment appended
to the end of this ParameterPath.
Sourcepub fn variant(self, name: &'static str) -> Self
pub fn variant(self, name: &'static str) -> Self
Returns a new ParameterPath with a ParameterPathSegment::Variant segment appended
to the end of this ParameterPath.
Sourcepub fn index(self, index: usize) -> Self
pub fn index(self, index: usize) -> Self
Returns a new ParameterPath with a ParameterPathSegment::Index segment appended
to the end of this ParameterPath.
Sourcepub fn tuple_index(self, index: usize) -> Self
pub fn tuple_index(self, index: usize) -> Self
Returns a new ParameterPath with a ParameterPathSegment::TupleIndex segment appended
to the end of this ParameterPath.
Sourcepub fn key<K: Debug>(self, key: K) -> Self
pub fn key<K: Debug>(self, key: K) -> Self
Returns a new ParameterPath with a ParameterPathSegment::Key segment appended
to the end of this ParameterPath.
Trait Implementations§
Source§impl Clone for ParameterPath
impl Clone for ParameterPath
Source§fn clone(&self) -> ParameterPath
fn clone(&self) -> ParameterPath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more