MCPcopy Create free account
hub / github.com/chanced/jsonptr / with_trailing_token

Method with_trailing_token

src/pointer.rs:509–513  ·  view source on GitHub ↗

Creates an owned [`PointerBuf`] like `self` but with `token` appended. See [`PointerBuf::push_back`] for more details. Note**: this method allocates. If you find yourself calling it more than once for a given pointer, consider using [`PointerBuf::push_back`] instead. ## Examples ``` let ptr = jsonptr::Pointer::from_static("/foo"); let foobar = ptr.with_trailing_token("bar"); assert_eq!(foobar,

(&self, token: impl Into<Token<'t>>)

Source from the content-addressed store, hash-verified

507 /// assert_eq!(foobar, "/foo/bar");
508 /// ```
509 pub fn with_trailing_token<'t>(&self, token: impl Into<Token<'t>>) -> PointerBuf {
510 let mut buf = self.to_buf();
511 buf.push_back(token.into());
512 buf
513 }
514
515 /// Creates an owned [`PointerBuf`] like `self` but with `token` prepended.
516 ///

Callers 1

with_trailing_tokenFunction · 0.80

Calls 2

to_bufMethod · 0.80
push_backMethod · 0.80

Tested by 1

with_trailing_tokenFunction · 0.64