News for hackers. Stuff that matters.
Re:Announcing Rust 1.15.1 by steveklabnik on Thursday February 09, 2017 @03:40PM (#13610739)
A Rustacean with a wry sense of humor suggested that now would be a good time to pitch the Underhanded Rust Contest https://underhanded.rs/blog/2016/12/15/underhanded-rust.en-U...
Re:Announcing Rust 1.15.1 by brinker on Thursday February 09, 2017 @03:22PM (#13610547)
Glad that the soundness bug was caught so quickly, and that the new version has been put out so quickly. Thanks Rust team!
Re:Announcing Rust 1.15.1 by saintfiends on Saturday February 11, 2017 @11:22AM (#13623225)
I'm new to rust. Can someone explain what is the issue with following code?

    pub fn as_mut_slice(&self) -> &mut [T] {
        unsafe {
            slice::from_raw_parts_mut(self.ptr as *mut T, self.len())
        }
    }
Re:Announcing Rust 1.15.1 by steveklabnik on Saturday February 11, 2017 @02:32PM (#13624280)
The post goes on to explain it, was there something specific about that that's confusing?
Re:Announcing Rust 1.15.1 by saintfiends on Sunday February 12, 2017 @12:35AM (#13626951)
My confusion was why the compiler didn't catch this, it is suppose to spot this sort of thing right?

Now that I think about it, maybe it has to do with `unsafe` block so the compiler doesn't check it.

My next question would be why does it need `unsafe`?

Re:Announcing Rust 1.15.1 by steveklabnik on Sunday February 12, 2017 @01:07AM (#13627044)
Ah yes, it's because of the `unsafe`.

> why does it need `unsafe`?

slice::from_raw_parts_mut is an unsafe function because it lets you conjure a slice from thin air; there's no checking of it at all.

This function is used because it's the most straightforward way of accomplishing the task.

Re:Announcing Rust 1.15.1 by baq on Thursday February 09, 2017 @04:22PM (#13611110)
Quick and responsible, good job.