Sunday, 15 July 2012

migration - Rust - How to migrate '\uXXXX' to new bytes string -



migration - Rust - How to migrate '\uXXXX' to new bytes string -

i'm wondering if there possibility translate next old rust code:

bytes!("a\u2028t")

into current language. seems bytes! deprecated b"" don't see way translate \u2028 byte string literal.

if want true byte string equivalent, you'll need find utf8 encoding of u+2028, e.g. via

fn main() { b in "\u2028".as_bytes().iter() { print!("\\x{:x}", *b) } }

which prints \xe2\x80\xa8 (i.e. in pre-encoded form), b"a\xe2\x80\xa8t" should work. also, above hints @ method: can utilize "a\u2028t".as_bytes(), although not work in static contexts.

migration rust

No comments:

Post a Comment