Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
trait Nameable<T> {
fn set_name(&mut self, T);
struct Cyborg{
name: Option<String>,
impl Nameable<&str> for Cyborg {
fn set_name(&mut self, s: &str) { = Some(s.to_string());
impl Nameable<usize> for Cyborg {
fn set_name(&mut self, serial_number: usize) { = Some(serial_number.to_string());
fn main() {
let mut mostly_human = Cyborg{name: None};
let mut mostly_machine = Cyborg{name: None};
println!("{} vs {}",,,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment