ralfbiedert / cheats.rs

Rust Language Cheat Sheet - https://cheats.rs
https://cheats.rs
4.14k stars 393 forks source link

Add guide for writing polymorphic code #65

Closed kud1ing closed 5 years ago

kud1ing commented 5 years ago

I think a guide would be nice that explains what to choose when writing polymorphic code (sort of the inverse of https://cheats.rs/#generics-constraints which explains what the syntax means if you see it in the wild).

See also:

Functions (arguments/return values)

dyn Trait

dynamic binding (trait object) => no monomorphization

impl Trait

static binding => monomorphization

generics

static binding? monomorphization?

Data structures

This may or may not fit https://cheats.rs/#generics-constraints

ralfbiedert commented 5 years ago

Is that when defining functions?

kud1ing commented 5 years ago

Good question. I've updated the text above.

ralfbiedert commented 5 years ago

Also closing this one as it seems to have stalled and I'm not quite sure how I would address this.

This is purely for "issue hygiene" and doesn't mean I'm opposed to the item. Please re-open / comment if there is any progress!