From be040518cc9e0843c238788094e222d13799e044 Mon Sep 17 00:00:00 2001 From: rusty-snake Date: Tue, 6 Aug 2019 09:15:30 +0000 Subject: [PATCH] generics/impl.md: follow rustfmt style --- src/generics/impl.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/generics/impl.md b/src/generics/impl.md index 6410739a67..69554316e0 100644 --- a/src/generics/impl.md +++ b/src/generics/impl.md @@ -4,39 +4,43 @@ Similar to functions, implementations require care to remain generic. ```rust struct S; // Concrete type `S` -struct GenericVal(T,); // Generic type `GenericVal` +struct GenericVal(T); // Generic type `GenericVal` // impl of GenericVal where we explicitly specify type parameters: impl GenericVal {} // Specify `f32` impl GenericVal {} // Specify `S` as defined above // `` Must precede the type to remain generic -impl GenericVal {} +impl GenericVal {} ``` ```rust,editable struct Val { - val: f64 + val: f64, } -struct GenVal{ - gen_val: T +struct GenVal { + gen_val: T, } // impl of Val impl Val { - fn value(&self) -> &f64 { &self.val } + fn value(&self) -> &f64 { + &self.val + } } // impl of GenVal for a generic type `T` -impl GenVal { - fn value(&self) -> &T { &self.gen_val } +impl GenVal { + fn value(&self) -> &T { + &self.gen_val + } } fn main() { let x = Val { val: 3.0 }; let y = GenVal { gen_val: 3i32 }; - + println!("{}, {}", x.value(), y.value()); } ```