Skip to content

Instantly share code, notes, and snippets.

@DarkFenX
Created May 29, 2020 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarkFenX/7228941223248d9ea9f5dec5ba1247e7 to your computer and use it in GitHub Desktop.
Save DarkFenX/7228941223248d9ea9f5dec5ba1247e7 to your computer and use it in GitHub Desktop.
trait Fk {
fn get_fks<T>(&self, remote: T) -> Vec<i32>;
}
struct Item {}
struct ItemGroup {}
impl Fk for Item {
fn get_fks<T>(&self, remote: T) -> Vec<i32> {
let mut vec = Vec::new();
match remote {
Item => vec.push(3),
}
vec
}
}
impl Fk for ItemGroup {
fn get_fks<T>(&self, _: T) -> Vec<i32> {
Vec::new()
}
}
fn main() {
let item = Item {};
let group = ItemGroup {};
println!("{:?}", item.get_fks(Item));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment