News for hackers. Stuff that matters.
Re:A half-hour to learn Rust by millstone on Saturday January 02, 2021 @03:16PM (#25616071)
I think both points are right. There's times when it's useful and desirable to be specific about lifetimes, and there's also times where it's annoying noise.

Bignum arithmetic is an example of the latter. You want to just work with numbers, and in Python you can, but in Rust you must clutter your code with lifetimes and borrows and clones.

Swift's plan to allow gradual, opt-in lifetime annotations seems really interesting, if it works.

Re:A half-hour to learn Rust by CDSlice on Saturday January 02, 2021 @05:21PM (#25617120)
Bignum arithmetic actually is pretty simple in Rust if you use the right library. Rug[0] makes using bignums look almost just like using native numbers through operator overloading.

[0] https://crates.io/crates/rug

Re:A half-hour to learn Rust by millstone on Saturday January 02, 2021 @05:52PM (#25617399)
The operator overloading is nice but you still get smacked in the face right away by the borrow checker. Simple stuff like this won't compile ("use of moved value"):

    let a = Integer::from(10);
    let b = a + a;
Re:A half-hour to learn Rust by pimeys on Sunday January 03, 2021 @06:02AM (#25621060)
This would work if `Integer` would implement the `Copy` trait. But I guess that type is heavy enough for it to be too expensive, therefore forcing you to explicitly call `clone()`.
Re:A half-hour to learn Rust by Measter on Sunday January 03, 2021 @07:21AM (#25621366)
That `Integer` type can't implement `Copy` because it manages a resource, meaning you can't just do a simple memcpy of the type.
Re:A half-hour to learn Rust by smmalis37 on Monday January 04, 2021 @01:04AM (#25628304)

  let b = &a + &a;
will work, but I agree it's unfortunate that this is necessary.