News for hackers. Stuff that matters.
Re:Immutable.rs: immutable data structures for Rust by jcelerier on Sunday April 08, 2018 @07:05AM (#16785588)
> copy-on-write-unless-we're-alone-then-just-mutate-without-copy

well, yes, that's generally called copy-on-write. A COW class which does a copy every time you write to it would be pretty useless, woudln't it ?

e.g. if you did, in old std::strings:

    std::string s = "foo";
    s[1] = "x"; // no copy here
    auto s2 = s; // no copy here;
    s[1] = "y"; // s is copied in a new buffer
    s[1] = "z"; // no copy here
    s2 += "bar"; // no copy here

There are no comments on this comment yet.