Created
February 28, 2017 13:58
-
-
Save stpettersens/e5ac850a5c05e1dddab92493350b78d3 to your computer and use it in GitHub Desktop.
Alias a structure/implementation and use it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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