ctaggart / octh

Rust bindings for GNU Octave oct.h
14 stars 4 forks source link

add From<bytes> for StdString #42

Closed ctaggart closed 4 years ago

ctaggart commented 4 years ago

See if we can simplify

let name = StdString::from_bytes_with_nul(b"helloworld\0");

to

let name: StdString = b"helloworld\0";

Also use CString to wrap a regular Rust string.

ctaggart commented 4 years ago

I couldn't get this to work with &[u8]. It complains about no implementation for &[u8;24] or similar. I think it needs constant generics. https://github.com/rust-lang/rust/issues/44580

I implemented it for &str.