Skip to content

Instantly share code, notes, and snippets.

@stivenson
Created July 1, 2019 02:54
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 stivenson/c6d2b44aff607bd0cf26acc0f2eb73eb to your computer and use it in GitHub Desktop.
Save stivenson/c6d2b44aff607bd0cf26acc0f2eb73eb to your computer and use it in GitHub Desktop.
Example of new trait to man struct
// other Code ...
trait Travel {
fn new(destination: &'static str) -> Self;
fn go(&self) -> &'static str;
}
impl Travel for Man {
fn new(destination: &'static str) -> Man {
// logic ...
}
fn go(&self) -> &'static str {
// logic ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment