Hi!

I’ve noticed this piece of code in your library:

#[inline]
fn as_mut_slice(&self) -> &mut [u8] {
    unsafe {
        match self {
            &OwnedBuffer(ref v) => {
                let mut_v: &mut Vec<u8> = mem::transmute(v);
                mut_v.as_mut_slice()
            },
            &BorrowedBuffer(ref s) => {
                let mut_s: &mut &mut [u8] = mem::transmute(s);
                mut_s.as_mut_slice()
            },
        }
    }
}

I was under impression that transmuting & to &mut is undefined behavior in 
Rust, and you need to use RefCell (or UnsafeCell) for this. Am I wrong?

On 04 сент. 2014 г., at 9:17, Clark Gaebel <cg.wowus...@gmail.com> wrote:

> Hey everyone!
> 
> Have you ever needed to communicate with the outside world from a rust 
> application? Do you need to send data through a network interface, or touch a 
> disk? Then you need Iobufs!
> 
> An Iobuf is a nifty abstraction over an array of bytes, which makes writing 
> things like highly efficient zero-copy speculative network protocol parsers 
> easy! Any time I need to do I/O, I reach for an Iobuf to do the heavy lifting.
> 
>             https://github.com/cgaebel/iobuf
> 
> Enjoy,
>   - Clark
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to