Unify single-char and multi-char CStrUnit::Char
handling.
The two cases are equivalent. C string literals aren't common so there is no performance need here.
This commit is contained in:
parent
29c5158ef5
commit
a50efe2653
@ -161,7 +161,6 @@ pub fn from_token_lit(lit: token::Lit) -> Result<LitKind, LitError> {
|
|||||||
error = Err(LitError::NulInCStr(span));
|
error = Err(LitError::NulInCStr(span));
|
||||||
}
|
}
|
||||||
Ok(CStrUnit::Byte(b)) => buf.push(b),
|
Ok(CStrUnit::Byte(b)) => buf.push(b),
|
||||||
Ok(CStrUnit::Char(c)) if c.len_utf8() == 1 => buf.push(c as u8),
|
|
||||||
Ok(CStrUnit::Char(c)) => {
|
Ok(CStrUnit::Char(c)) => {
|
||||||
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
|
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user