Skip to main content
Remove extra closing parenthesis
Source Link
Evan Shaw
  • 24.7k
  • 8
  • 72
  • 62

Using .to_string() will allocate String on heap. Usually it's not any issue, but if you wish to avoid this and want to get &str slice directly, you may alternatively use

let mut tmp = [0u8; 4]; let your_string = c.encode_utf8(&mut tmp)); 

Using .to_string() will allocate String on heap. Usually it's not any issue, but if you wish to avoid this and want to get &str slice directly, you may alternatively use

let mut tmp = [0u8; 4]; let your_string = c.encode_utf8(&mut tmp)); 

Using .to_string() will allocate String on heap. Usually it's not any issue, but if you wish to avoid this and want to get &str slice directly, you may alternatively use

let mut tmp = [0u8; 4]; let your_string = c.encode_utf8(&mut tmp); 
Source Link
alagris
  • 2.3k
  • 26
  • 45

Using .to_string() will allocate String on heap. Usually it's not any issue, but if you wish to avoid this and want to get &str slice directly, you may alternatively use

let mut tmp = [0u8; 4]; let your_string = c.encode_utf8(&mut tmp));