Into<String> better than AsRef<str>
This commit is contained in:
@ -19,7 +19,11 @@ impl Translator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Translator {
|
impl Translator {
|
||||||
pub fn convert<S: AsRef<str>>(&mut self, s: S) -> IdType {
|
pub fn convert(&mut self, s: impl Into<String>) -> IdType {
|
||||||
*(self.strings.entry(s.as_ref().to_string()).or_insert({self.last_id += 1; self.last_id}))
|
*(self.strings.entry(s.into()).or_insert(
|
||||||
|
{self.last_id += 1;
|
||||||
|
self.last_id
|
||||||
|
}
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user