Returns the first `Token` in the `Pointer`.
(&self)
| 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 | /// |