Follow

Based on the docs, Rust's numeric libraries consist mostly of hundreds of trait implementations. How do people figure out what to use?

I'm used to Go where you don't know or care about all the interfaces that a type might satisfy, but you do see all its methods, which is what you really need anyway.

@skybrian you can see the methods too!
for example if you're looking at `u64` and you want to see the methods that it satisfies, you can click the trait and it'll show you what methods it has. Like this: doc.rust-lang.org/std/primitiv

One of Rusts problems IMO is that it doesn't have great polymorphism for primitive types (these are for a good reason too—Rust is very strictly typed and doesn't want to deal with random type conversion here) so there are a lot of trait implementations for the default types for things to work

but i think they structured the documentation in a way that makes sense

@pounce Yeah, I see that, but I think it would be easier to use with an alphabetical list of methods and the associated traits deemphasized somehow. Maybe I should write a better doc generator. (Or get autocomplete working in VS Code.)

@skybrian
Autocomplete would probably be the easiest
VSCode is one of the most popular rust editors and they put a lot of work into making it work well (it's one of the only ones that integrates with the rust language server)

@pounce
It looks like Rust autocomplete in VS Code doesn't work with type inference, which is why I thought it wasn't working. You can get it to work by explicitly declaring the type of a variable.

They are saying it's not going to be fixed in the Rust language server until they can use the Rust compiler to do autocompletions instead of Racer.

Apparently IntelliJ does not use racer and implemented type inference themselves:
reddit.com/r/rust/comments/715

(But having using IntelliJ for many years, I'm reluctant to switch back to it again just for one feature. It's pretty heavyweight.)

@skybrian
Oh that's interesting! Sorry for the misinformation—i don't use an IDE (except for in my job bc they make me and I use WS for typescript)
I didn't think about type inference, that's a weird problem

Sign in to participate in the conversation
Mastodon

cmpwn.com is a private Mastodon instance for friends of SirCmpwn.