B:BD[
4.23214] → [
4.23214:23246]
return Some(())
Some(())
},
None => None,
}
}
fn peek(&self) -> Option<()> {
match self.top_token().next() {
Some(_) => Some(()),
None => None,
}
}
pub fn assert_unique_top_token(&self) -> Result<()> {
match self.peek() {
None => Ok(()),
_ => Err(Error::new(ErrorKind::EUniqueTokenFMany)),
}
}
pub fn val<T>(&self, key_path: &str) -> Result<T>
where
T: FromStr,
KeyTreeRef<'a>: TryInto<T>,
KeyTreeRef<'a>: TryInto<T, Error = Error>,
{
let path = KeyPath::from_str(key_path);
let kt = self.recurse(&path)?;
kt.assert_unique_top_token()?;
match kt.top_token() {
Token::KeyValue { key, value, .. } => {
match T::from_str(value) {
Ok(t) => Ok(t),
Err(err) => {
Err(Error::new(ErrorKind::FromStr(
format!("{}: {}", key, value),
format!("{}", kt.1),
)))
},
}