Eliminate to_string() in Ident comparisons
diff --git a/src/lit.rs b/src/lit.rs
index a1e5844..e31dd62 100644
--- a/src/lit.rs
+++ b/src/lit.rs
@@ -432,9 +432,9 @@
_ => match input.term() {
Some((term, rest)) => Ok((
Lit::Bool(LitBool {
- value: if term.to_string() == "true" {
+ value: if term == "true" {
true
- } else if term.to_string() == "false" {
+ } else if term == "false" {
false
} else {
return parse_error();
diff --git a/src/parsers.rs b/src/parsers.rs
index 810a112..bdd0c6a 100644
--- a/src/parsers.rs
+++ b/src/parsers.rs
@@ -1305,7 +1305,7 @@
match <$crate::Ident as $crate::synom::Synom>::parse($i) {
::std::result::Result::Err(err) => ::std::result::Result::Err(err),
::std::result::Result::Ok((token, i)) => {
- if token.to_string() == stringify!($keyword) {
+ if token == stringify!($keyword) {
::std::result::Result::Ok((token, i))
} else {
$crate::parse_error()
diff --git a/src/path.rs b/src/path.rs
index 7e83daf..a4495a2 100644
--- a/src/path.rs
+++ b/src/path.rs
@@ -233,7 +233,7 @@
named!(parse -> Self, do_parse!(
colon: option!(punct!(::)) >>
segments: call!(Punctuated::<PathSegment, Token![::]>::parse_separated_nonempty) >>
- cond_reduce!(segments.first().map_or(true, |seg| seg.value().ident.to_string() != "dyn")) >>
+ cond_reduce!(segments.first().map_or(true, |seg| seg.value().ident != "dyn")) >>
(Path {
leading_colon: colon,
segments: segments,
diff --git a/src/token.rs b/src/token.rs
index b195fda..7f2ebd7 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -351,7 +351,7 @@
fn parse(input: ::buffer::Cursor) -> ::synom::PResult<Underscore> {
match input.term() {
Some((term, rest)) => {
- if term.to_string() == "_" {
+ if term == "_" {
Ok((Underscore([term.span()]), rest))
} else {
::parse_error()
@@ -795,7 +795,7 @@
new: fn(Span) -> T,
) -> PResult<'a, T> {
if let Some((term, rest)) = tokens.term() {
- if term.to_string() == keyword {
+ if term == keyword {
return Ok((new(term.span()), rest));
}
}