17
gibus
23d

Strings in most languages:
(☞゚ヮ゚)☞ foo: string = "bar"

Strings in rust:
(╯‵□′)╯︵ AHHHHHHH!
borrowed value does not live long enough
types differ in mutability
cannot assign twice to immutable variable

Comments
  • 0
  • 8
    Strings are pretty complex in pretty much every language with manual memory management.

    If you thought strings were simple in C/C++, wait till you have to work with a ton of them in a large scale application.
  • 3
    Reassigning immutes is disallowed in all the languages
  • 1
    TypeScript?
  • 1
    While i think rust sucks ass and id much rather use c

    1) simple scoping issue, at least the error is explicit
    2) this usually happens when you try to modify an immutable thing in place, which makes sense
    3) yeah

    The real mindfuck is when you start using libraries and half of them have mutable variables and the other half only uses references.
  • 5
    None of those errors are specific to strings though, they're lifetime/mutability errors which would just as well apply to other values. But I get your frustration.

    It takes a bit to get used to Rust memory trickery... but when it clicks, it's like "well duh, that just seems like a good practice". Rust just points out things which could actually cause errors in other languages as well.

    But it does take a few weekends of stabbing with a rusty knife at some pet projects while occasionally throwing objects through your room, before you get used to it.
  • 2
    In C you just have char*

    This can be many kinds of string! It only seems like one. It can be String, &str, &'static str, OsString and many more.

    I'd rather have them as separate types because then at least the compiler tells you when you have a bug instead of finding out in production.

    Also, don't be afraid to clone! Other languages do this implicitly
  • 1
    @Geoxion And in C you have no idea who owns that little pumpkin patch of memory.

    Rust multithreading & async is like immersing yourself in a godly S-tier chocolate fountain and thinking "so this is what sweet warm dessert sauce feels like when it flows over my balls".

    Sorry, be right back, have to masturbate a bit.

    https://blog.rust-lang.org/2015/04/...
  • 0
    @bittersweet it's all because mut &str is a lie.
Add Comment