Comment

Comment by comex

You can, but idiomatic Rust code looks pretty different from idiomatic C code - to give a concrete example,

    int get_a_string(char **out) // returns error code
could be translated literally as

    fn get_a_string(out: *mut *mut c_char) -> c_int
but much preferable would be

    fn get_a_string() -> Result<String, Errcode>
[where Result and String are standard library types; Errcode would be a custom enum.]

I suppose you could go from the first to the second incrementally, then refactor to the third. But I'm not sure it'd work well.

parent comex 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton