Trait Segment

Source
pub trait Segment<T> {
    // Required method
    fn join(&self, other: T) -> Path;
}
Expand description

Shared behavior for types that can be combined to create a Path.

Required Methods§

Source

fn join(&self, other: T) -> Path

Combines self with other. Returns a new Path.

§Example
use json_api::value::fields::{Key, Path, Segment};

let posts = "posts".parse::<Key>()?;
let comments = "comments".parse::<Key>()?;

let path: Path = posts.join(&comments);
assert_eq!(path, "posts.comments");

let authors = "authors".parse::<Key>()?;
let name = "name".parse::<Key>()?;

let path: Path = path.join(&authors.join(&name));
assert_eq!(path, "posts.comments.authors.name");

Implementors§

Source§

impl Segment<Key> for Key

Source§

impl Segment<Key> for Path

Source§

impl<'a> Segment<&'a Key> for Key

Source§

impl<'a> Segment<&'a Key> for Path

Source§

impl<'a, T> Segment<T> for Key
where T: IntoIterator<Item = &'a Key>,

Source§

impl<'a, T> Segment<T> for Path
where T: IntoIterator<Item = &'a Key>,