News for hackers. Stuff that matters.
Re:Show HN: Bolt: A research language with finer-grained con... by _bxg1 on Sunday May 10, 2020 @12:36AM (#23130327)
> Rust doesn’t support this out of the box, but you can get something equivalent with the owning_ref crate

Rust does come with something like this out of the box for the case of arrays: https://doc.rust-lang.org/std/primitive.slice.html#method.sp...

Re:Show HN: Bolt: A research language with finer-grained con... by comex on Sunday May 10, 2020 @03:54AM (#23131014)
split_at_mut is for borrowed references. That's the case where I said it does work out of the box with fields, since you can take mutable references to disjoint fields, and the borrow checker allows it without you having to do anything special. But if you want to take an owned pointer to an object and split it into owned pointers to its subcomponents (which only makes sense with Rc), I don't think the standard library has a way to do that for either fields or arrays.
Re:Show HN: Bolt: A research language with finer-grained con... by _bxg1 on Sunday May 10, 2020 @09:53AM (#23132573)
Ah, that makes sense my mistake
Re:Show HN: Bolt: A research language with finer-grained con... by saagarjha on Sunday May 10, 2020 @03:11AM (#23130882)
I wonder if Rust could provide some sort of “disjoint slice” type that would allow for this method to take a predicate for more complex divisions. (Interestingly, this exact use case is one of the few places where C++’s stringent iterator invalidation requirements come in handy, because they let you pass unordered_map buckets safely to different threads.)
Re:Show HN: Bolt: A research language with finer-grained con... by mrathi12 on Sunday May 10, 2020 @07:40AM (#23131884)
This is all unsafe code under the hood though - the ownership type system doesn't technically allow it but to increase expressivity they do provide this split() method for programmers to use
Re:Show HN: Bolt: A research language with finer-grained con... by _bxg1 on Sunday May 10, 2020 @09:52AM (#23132566)
split() itself is externally safe. Lots of stuff in the standard library is unsafe under the hood, including some of the core data structures.
Re:Show HN: Bolt: A research language with finer-grained con... by shigeo on Sunday May 10, 2020 @12:03PM (#23133630)
Why does that matter?