@Corax42@mastodon.social avatar

Corax42

@Corax42@mastodon.social

Ghastly, grim and ancient raven wandering from the nightly shore.

This profile is from a federated server and may be incomplete. For a complete list of posts, browse on the original instance.

became_fish , to random
@became_fish@jorts.horse avatar

people say "C++ isn't any closer to the metal than is" but what is the memory footprint of returning a Result? in C++ i can pass an out parameter by reference to avoid allocating anything on the stack - how do i do that in rust? is it with a &mut ptr? is it done automatically by the compiler when returning?

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.

Corax42 ,
@Corax42@mastodon.social avatar

@became_fish Oh, okay

Corax42 ,
@Corax42@mastodon.social avatar

@became_fish @kornel Yes, necessarily, because each String is the unique owner of its buffer, and the &str is borrowed from another owner.

lowqualityfacts , to random
@lowqualityfacts@mstdn.social avatar

I could never live there.
https://patreon.com/lowqualityfacts

Corax42 ,
@Corax42@mastodon.social avatar

@lowqualityfacts Technically we do have frogs, but they're all enchanted princes, so they don't count.

lowqualityfacts , to random
@lowqualityfacts@mstdn.social avatar

Here's some tips for all the newcomers on here:

-Introduce yourself by announcing who your least favorite Smurf is. It is standard.

-If you wish to verify your account, please upload a picture of your face to confirm that you are not Chris Brown. Chris is not allowed on here.

-Socialize by finding one person and commenting "This does not make me want to destroy you." on every single one of their posts.

Corax42 ,
@Corax42@mastodon.social avatar

@lowqualityfacts This kinda does make me want to destroy you.

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