DEV Community

Discussion on: Some Learnings from Implementing a Normalizing Rust Representer

pickfire profile image
Ivan Tham

Typo to_strong. Is it necessary to use to_string on every identifier when checking if it exists in hashmap? Why not &str?

seanchen1991 profile image
Sean Chen Author

That's a good observation. ident is a type from the syn crate that, from what I can tell, is a wrapper around a String:

So in this case, the to_string() method on ident isn't the same to_string() method on a string slice. It's necessary to call it in order to work with the underlying string representation of the identifier.