Skip to content

Instantly share code, notes, and snippets.

@rinfz
Created September 27, 2019 14:37
Show Gist options
  • Save rinfz/191f1fe289015e506a228dfa80fd5958 to your computer and use it in GitHub Desktop.
Save rinfz/191f1fe289015e506a228dfa80fd5958 to your computer and use it in GitHub Desktop.
struct Foo {
data: Vec<f64>,
}
trait FileData {
fn new(raw_data: &[u8]) -> Self;
fn get_data(&self) -> &Vec<f64> {
&self.data
}
fn default_method(&self) -> f64 {
self.get_data().first() * self.get_data().last()
}
}
impl FileData for Foo {
fn new(raw_data: &[u8]) -> Self {
// something
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment