Added line to BadIndent error.
[?]
Mar 7, 2021, 12:49 PM
VDFODD2FXIZGSSAH63WL56JGHDZQLVOZXOAAWQ3KKHXH66UCKMAACDependencies
- [2]
6ZJX2OQVFirst commit
Change contents
- edit in src/path.rs at line 1
//! A path such as `hobbit::friend`, used to select a key in//! the tree. - edit in src/path.rs at line 9
////// For example the keypath `"hobbit::friends"` will select the tree of two/// hobbits Frodo and Samwise from the following keytree. `"hobbit:age"` will/// select Frodo's age.////// ```/// hobbit:/// name: Frodo Baggins/// age: 60/// friends:/// hobbit:/// name: Bilbo Baggins/// age: 111/// hobbit:/// name: Samwise Gamgee/// age: 38/// nick: Sam/// ``` - replacement in src/path.rs at line 10
pub struct KeyPath(pub Vec<String>);pub(crate) struct KeyPath(pub Vec<String>); - replacement in src/path.rs at line 30
pub (crate) fn from_str(s: &str) -> Self {pub(crate) fn from_str(s: &str) -> Self { - replacement in src/parser.rs at line 266
let indent = indent(&mut root_indent, line_start, start_key).map_err(|e| e.from_inner(&token))?;let indent = indent(&mut root_indent,line_start,start_key).map_err(|e| e.from_inner(&token, line))?; - replacement in src/parser.rs at line 282
let indent = indent(&mut root_indent, line_start, start_key).map_err(|e| e.from_inner(&token))?;let indent = indent(&mut root_indent,line_start,start_key).map_err(|e| e.from_inner(&token, line))?; - replacement in src/parser.rs at line 298
let indent = indent(&mut root_indent, line_start, start_key).map_err(|e| e.from_inner(&token))?;let indent = indent(&mut root_indent,line_start,start_key).map_err(|e| e.from_inner(&token, line))?; - replacement in src/parser.rs at line 347
return Err(Error::new(ErrorKind::NoColonAfterKey(token_str.to_string())));return Err(Error::new(ErrorKind::NoColonAfterKey(token_str.to_string()))); - replacement in src/parser.rs at line 355
return Err(Error::new(ErrorKind::IncompleteCommentOrKey(token_str.to_string())));return Err(Error::new(ErrorKind::IncompleteCommentOrKey(token_str.to_string()))); - replacement in src/parser.rs at line 365
return Err(Error::new(ErrorKind::NoSpaceAfterKey));return Err(Error::new(ErrorKind::NoSpaceAfterKey)); - replacement in src/parser.rs at line 374
return Err(Error::new(ErrorKind::IncompleteLine(String::from("/"))))return Err(Error::new(ErrorKind::IncompleteLine(String::from("/")))) - replacement in src/parser.rs at line 383
return Err(Error::new(ErrorKind::IncompleteLine(token_str.to_string())));return Err(Error::new(ErrorKind::IncompleteLine(token_str.to_string()))); - replacement in src/parser.rs at line 394
return Err(Error::new(ErrorKind::ColonBeforeKey));return Err(Error::new(ErrorKind::ColonBeforeKey)); - replacement in src/parser.rs at line 400
return Err(Error::new(ErrorKind::ColonBeforeKey));return Err(Error::new(ErrorKind::ColonBeforeKey)); - replacement in src/parser.rs at line 405
return Err(Error::new(ErrorKind::NoSpaceAfterKey));return Err(Error::new(ErrorKind::NoSpaceAfterKey)); - replacement in src/parser.rs at line 414
return Err(Error::new(ErrorKind::IncompleteCommentOrKey(token_str.to_string())));return Err(Error::new(ErrorKind::IncompleteCommentOrKey(token_str.to_string()))); - replacement in src/parser.rs at line 421
return Err(Error::new(ErrorKind::NoSpaceAfterKey));return Err(Error::new(ErrorKind::NoSpaceAfterKey)); - replacement in src/parser.rs at line 436
return Err(Error::new(ErrorKind::IncompleteCommentOrKey(token_str.to_string())));return Err(Error::new(ErrorKind::IncompleteCommentOrKey(token_str.to_string(),))); - replacement in src/parser.rs at line 445
return Err(Error::new(ErrorKind::IncompleteLine(token_str.to_string())));return Err(Error::new(ErrorKind::IncompleteLine(token_str.to_string()))); - replacement in src/parser.rs at line 454
key: &s[start_key..s.chars().count() - 1],children: Vec::new(),next: None,line: Line::new(line),key: &s[start_key..s.chars().count() - 1],children: Vec::new(),next: None,line: Line::new(line), - replacement in src/parser.rs at line 459
let indent = indent(&mut root_indent, line_start, start_key).map_err(|e| e.from_inner(&token))?;let indent = indent(&mut root_indent,line_start,start_key).map_err(|e| e.from_inner(&token, line))?; - replacement in src/parser.rs at line 474
let indent = indent(&mut root_indent, line_start, start_key).map_err(|e| e.from_inner(&token))?;let indent = indent(&mut root_indent,line_start,start_key).map_err(|e| e.from_inner(&token, line))?; - replacement in src/parser.rs at line 484
key: &s[start_key..=end_key],value: &s[start_val..],next: None,line: Line::new(line),key: &s[start_key..=end_key],value: &s[start_val..],next: None,line: Line::new(line), - replacement in src/parser.rs at line 489
let indent = indent(&mut root_indent, line_start, start_key).map_err(|e| e.from_inner(&token))?;let indent = indent(&mut root_indent,line_start,start_key).map_err(|e| e.from_inner(&token, line))?; - replacement in src/parser.rs at line 521
let chars_indent = start_key - line_start - *root_indent;let chars_indent = start_key -line_start -*root_indent; - replacement in src/parser.rs at line 526
return Err(Error::new(ErrorKind::InnerBadIndent(chars_indent)));return Err(Error::new(ErrorKind::InnerBadIndent(chars_indent))); - replacement in src/lib.rs at line 11
pub mod parser;pub mod path;// impl<'a> Display for Token<'a> {// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {// match self {// Token::Key { line, .. } => write!(f, "{}", line),// Token::KeyValue { line, .. } => write!(f, "{}", line),// }// }// }pub(crate) mod parser;pub(crate) mod path; - edit in src/lib.rs at line 16
/// Indicates line number for error messages. - replacement in src/lib.rs at line 35
pub enum Token<'a> {pub(crate) enum Token<'a> { - edit in src/lib.rs at line 93
// fn new(s: &'a str) -> Self {// Token::Key {// key: s,// children: Vec::new(),// next: None,// }// } - edit in src/lib.rs at line 153
// impl<'a, T> TryInto<T> for KeyTree<'a> {// type Error = Error;//// fn try_into(self) -> std::result::Result<T, Self::Error> {// self.to_ref().try_into()// }// } - replacement in src/lib.rs at line 177
/// Coerces the value at key_path from a string to the receiver type./// See top page for an example./// Coerces the value at key_path from a string to the/// receiver type. See top page for an example. - replacement in src/lib.rs at line 181
KeyTreeRef<'a>: TryInto<T>,KeyTreeRef<'a>: TryInto<T, Error = Error>,KeyTreeRef<'a>: TryInto<T>,KeyTreeRef<'a>: TryInto<T, Error = Error>, - replacement in src/lib.rs at line 196
/// Coerces the value at key_path from a string to `Some` of the receiver/// type, or None if there is nothing at key_path. See top page for example./// Coerces the value at key_path from a string to/// Some` of the receiver type, or None if there is/// nothing at key_path. See top page for example. - replacement in src/lib.rs at line 201
KeyTreeRef<'a>: TryInto<T>,KeyTreeRef<'a>: TryInto<T, Error = Error>,KeyTreeRef<'a>: TryInto<T>,KeyTreeRef<'a>: TryInto<T, Error = Error>, - replacement in src/lib.rs at line 210
// Check that top token is unique// Check that top token is unique. - replacement in src/lib.rs at line 228
KeyTreeRef<'a>: TryInto<T>,KeyTreeRef<'a>: TryInto<T, Error = Error>,KeyTreeRef<'a>: TryInto<T>,KeyTreeRef<'a>: TryInto<T, Error = Error>, - replacement in src/lib.rs at line 247
pub (crate) fn recurse(&self, path: &KeyPath) -> Result<KeyTreeRef<'a>> {pub (crate) fn recurse(&self,path: &KeyPath) -> Result<KeyTreeRef<'a>>{ - replacement in src/lib.rs at line 273
return Err(Error::new(ErrorKind::EKeyFKeyValue))return Err(Error::new(ErrorKind::EKeyFKeyValue)) - replacement in src/lib.rs at line 281
return Err(Error::new(ErrorKind::NoChildWithSegment(self.top_token().to_string(),self.top_token().line().to_string(),key.to_string(),)))return Err(Error::new(ErrorKind::NoChildWithSegment(self.top_token().to_string(),self.top_token().line().to_string(),key.to_string(),))) - replacement in src/lib.rs at line 296
pub (crate) fn op_recurse(&self, path: &KeyPath) -> Result<Option<KeyTreeRef<'a>>> {pub (crate) fn op_recurse(&self,path: &KeyPath) -> Result<Option<KeyTreeRef<'a>>>{ - replacement in src/lib.rs at line 304
ErrorKind::NoChildWithSegment(_, _, _) | ErrorKind::EKeyFKeyValue => Ok(None),ErrorKind::NoChildWithSegment(_, _, _)| ErrorKind::EKeyFKeyValue => {Ok(None)}, - edit in src/into.rs at line 1
//! Conversions from the value of a key/value pair.//!//! Conversions can be implemented by the client.//! `from_str` is a helper function that takes a description//! of the type being converted into, for use in error//! messages.//!//! ```//! impl<'a> TryInto<f32> for KeyTreeRef<'a> {//! type Error = Error;//!//! fn try_into(self) -> Result<f32> {//! self.from_str("f32")//! }//! }//! ``` - replacement in src/error.rs at line 24
pub fn from_inner<T: Display>(self, token: T) -> Error {pub fn from_inner<T: Display>(self,token: T,line: usize) -> Error{ - replacement in src/error.rs at line 31
Error::new(ErrorKind::BadIndent(token.to_string(), indent))Error::new(ErrorKind::BadIndent(token.to_string(), line, indent)) - replacement in src/error.rs at line 61
// BadIndent(token as string, chars indented relative to root key)BadIndent(String, usize),// BadIndent(token as string, line, chars indented relative to root key)BadIndent(String, usize, usize), - replacement in src/error.rs at line 115
ErrorKind::BadIndent(_, _) => None,ErrorKind::BadIndent(_, _, _) => None, - replacement in src/error.rs at line 181
ErrorKind::BadIndent(token, indent) => {ErrorKind::BadIndent(token, line, indent) => { - replacement in src/error.rs at line 183
"Indent of \"{}\" relative to root key is {} but must be multiple of 4.","Indent of \"{}: {}\" on relative to root key is {} but must be multiple of 4.",line, - edit in src/builder.rs at line 13
dbg!(&self.0); - replacement in examples/hobbit/src/main.rs at line 19
name: String,age: u32,name: String,age: u32, - replacement in examples/hobbit/src/main.rs at line 22
nick: Option<String>,nick: Option<String>, - replacement in examples/hobbit/src/main.rs at line 31
name: self.at("hobbit::name")?,age: self.at("hobbit::age")?,friends: self.vec("hobbit::friends::hobbit")?,nick: self.op("hobbit::nick")?,name: self.at("hobbit::name")?,age: self.at("hobbit::age")?,friends: self.vec("hobbit::friends::hobbit")?,nick: self.op("hobbit::nick")?,