Skip to content

Instantly share code, notes, and snippets.

@stpettersens
Created February 28, 2017 13:58
Show Gist options
  • Save stpettersens/e5ac850a5c05e1dddab92493350b78d3 to your computer and use it in GitHub Desktop.
Save stpettersens/e5ac850a5c05e1dddab92493350b78d3 to your computer and use it in GitHub Desktop.
Alias a structure/implementation and use it.
pub struct Dummy {
foo: String,
bar: String,
}
impl Dummy {
pub fn new(foo: &str, bar: &str) -> Dummy {
Dummy {
foo: foo.to_owned(),
bar: bar.to_owned(),
}
}
pub fn print(&self) {
println!("I have {} and {}.", self.foo, self.bar);
}
}
use Dummy as D;
fn main() {
let d = D::new("foo", "bar");
d.print();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment