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§
Sourcefn join(&self, other: T) -> Path
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");