Skip to content

Commit

Permalink
fix!: Parse ! as negation instead of -, as per the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
glennib committed Jan 6, 2025
1 parent 7b40c31 commit 97e038c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn main() {
}

// Select fields to exclude
let tree = Tree::parse("-(bio)").unwrap();
let tree = Tree::parse("!(bio)").unwrap();

assert!(tree.negation());
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//! }
//!
//! // Select fields to exclude
//! let tree = Tree::parse("-(bio)").unwrap();
//! let tree = Tree::parse("!(bio)").unwrap();
//!
//! assert!(tree.negation());
//! ```
Expand Down
4 changes: 2 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'s> FieldsStruct<'s> {

impl<'s> Fields<'s> {
fn parse(input: &mut &'s str) -> PResult<Self> {
let negation = opt('-').parse_next(input)?.is_some();
let negation = opt('!').parse_next(input)?.is_some();
let fields_struct = FieldsStruct::parse.parse_next(input)?;
Ok(Self {
fields_struct,
Expand Down Expand Up @@ -153,7 +153,7 @@ mod tests {

#[test]
fn fields() {
let s = "-(field_a)";
let s = "!(field_a)";
let fields: Fields = s.try_into().unwrap();
assert!(fields.negation);
let field_items = fields.fields_struct.0.0;
Expand Down

0 comments on commit 97e038c

Please sign in to comment.