Corax42 ,
@Corax42@mastodon.social avatar

@became_fish Why do you have a Vec<char> to begin with?

Fundamentally, the problem with this setup is that a str is a sequence of utf8 bytes, where each char is variable-length encoded and ends up taking between 1 to 4 bytes. But a slice of chars is a fixed-length encoding, where every char takes 4 bytes. Due to that mismatch, it should be impossible to convert a slice of a Vec<char> into a str without allocating a new buffer.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • test
  • worldmews
  • mews
  • All magazines