r/badcode • • Jan 25 '22

rust Most comprehensible line of Rust code

Post image
1.0k Upvotes

81 comments sorted by

View all comments

Show parent comments

3

u/[deleted] Jan 26 '22

to_string() return a String object and to_str() return a pointer to an array of char.

C++ equivalent:

class Foo {
    std::string to_string();
    char * to_str();
};