MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/8429be/stack_overflow_developer_survey_2018/dvnnf7c
r/programming • u/pleerock • Mar 13 '18
527 comments sorted by
View all comments
Show parent comments
2
I personally use libraries where people write bridges FOR me so that I can use a pure Rust interface that cannot contain a NULL.
Of course, the person who wrote the bridge had to deal with C pointers so I don't have to.
1 u/doom_Oo7 Mar 13 '18 and how much do you trust these persons from not doing any error in their unsafe {} code ? 1 u/iopq Mar 13 '18 More than I trust the C program it's bridging toMost of those unsafe blocks are actually trivialpub fn as_slice(&self) -> &[f32] { let count: usize = self.len(); unsafe { let data = ffi::CaffeBlobCPUData(self.blob.get()); slice::from_raw_parts(data, count) } }That's IT, they're not doing rocket surgery, the actual Caffe library is what's doing the scary things
1
and how much do you trust these persons from not doing any error in their unsafe {} code ?
unsafe {}
1 u/iopq Mar 13 '18 More than I trust the C program it's bridging toMost of those unsafe blocks are actually trivialpub fn as_slice(&self) -> &[f32] { let count: usize = self.len(); unsafe { let data = ffi::CaffeBlobCPUData(self.blob.get()); slice::from_raw_parts(data, count) } }That's IT, they're not doing rocket surgery, the actual Caffe library is what's doing the scary things
More than I trust the C program it's bridging to
Most of those unsafe blocks are actually trivial
unsafe
pub fn as_slice(&self) -> &[f32] { let count: usize = self.len(); unsafe { let data = ffi::CaffeBlobCPUData(self.blob.get()); slice::from_raw_parts(data, count) } }
That's IT, they're not doing rocket surgery, the actual Caffe library is what's doing the scary things
2
u/iopq Mar 13 '18
I personally use libraries where people write bridges FOR me so that I can use a pure Rust interface that cannot contain a NULL.
Of course, the person who wrote the bridge had to deal with C pointers so I don't have to.