We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e92c948 commit 3909c43Copy full SHA for 3909c43
src/serialization/ascii_char.rs
@@ -28,10 +28,11 @@ impl<'de> Visitor<'de> for AsciiCharVisitor {
28
29
#[inline]
30
fn visit_str<E: Error>(self, v: &str) -> Result<Self::Value, E> {
31
- let mut iter = v.chars();
32
- match (iter.next(), iter.next()) {
33
- (Some(c), None) => self.visit_char(c),
34
- _ => Err(Error::invalid_value(Unexpected::Str(v), &self)),
+ if v.len() == 1 {
+ let c = v.chars().next().unwrap();
+ self.visit_char(c)
+ } else {
35
+ Err(Error::invalid_value(Unexpected::Str(v), &self))
36
}
37
38
0 commit comments