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

Method front

src/pointer.rs:159–171  ·  view source on GitHub ↗

Returns the first `Token` in the `Pointer`.

(&self)

Source from the content-addressed store, hash-verified

157
158 /// Returns the first `Token` in the `Pointer`.
159 pub fn front(&self) -> Option<Token> {
160 if self.is_root() {
161 return None;
162 }
163 self.0[1..]
164 .split_once('/')
165 // SAFETY: source pointer is encoded
166 .map_or_else(
167 || unsafe { Token::from_encoded_unchecked(&self.0[1..]) },
168 |(front, _)| unsafe { Token::from_encoded_unchecked(front) },
169 )
170 .into()
171 }
172
173 /// Returns the first `Token` in the `Pointer`.
174 ///

Callers 1

firstMethod · 0.80

Calls 1

is_rootMethod · 0.80

Tested by

no test coverage detected