Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not only legacy, many hardware vendors provide only C bindings leaving the management of resources to the user.


How many hardware vendors provide any kind of Rust bindings at all? Let's compare like with like.


Maybe a more fair example would be std::fstream from C++, which takes a `char const ` (no size integer) or a `std::string` (a.k.a. string buffer) as constructor arguments. In the most idiomatic C++ possible, the standard library would support two character iterators.

In Rust, the equivalent might be:

  let ioResult = File::open(&Path::new("foo.txt"));
...no unsafe pointers or mandatory allocation necessary (1). Plus you're forced to check your error condition by unwrapping the returned value.

I don't bring that up to pick a nit, but to point out that this is basically the state-of-the-art (well, the char might be paired with a size_t) for passing strings through C++ APIs.

(1) I'm not sure whether Path::new actually allocates, but there's nothing stopping you from implementing a tight-and-fast InPlacePath that works seamlessly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: