From de98a0b8fec7fb4539307caea667112fe107bfce Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 5 Aug 2015 15:31:19 -0400 Subject: [PATCH 1/2] Add an example to Trait section of reference Fixes #26115 --- src/doc/reference.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index fdb45c32a1d60..e905ed917d7fd 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1501,7 +1501,29 @@ have an implementation for `Shape`. Multiple supertraits are separated by `+`, `trait Circle : Shape + PartialEq { }`. In an implementation of `Circle` for a given type `T`, methods can refer to `Shape` methods, since the typechecker checks that any type with an implementation of `Circle` also has an -implementation of `Shape`. +implementation of `Shape`: + +```rust +struct Foo; + +trait Shape { fn area(&self) -> f64; } +trait Circle : Shape { fn radius(&self) -> f64; } +# impl Shape for Foo { +# fn area(&self) -> f64 { +# 0.0 +# } +# } +impl Circle for Foo { + fn radius(&self) -> f64 { + println!("calling area: {}", self.area()); + + 0.0 + } +} + +let c = Foo; +c.radius(); +``` In type-parameterized functions, methods of the supertrait may be called on values of subtrait-bound type parameters. Referring to the previous example of From fc3df01eee84f5684bca4403dd501e08a3025035 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 6 Aug 2015 00:48:57 +0200 Subject: [PATCH 2/2] doc: add info about the u64 wrapped in Result --- src/libstd/fs.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index e5f2fcbae8394..a3f9f933bd993 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -854,6 +854,8 @@ pub fn rename, Q: AsRef>(from: P, to: Q) -> io::Result<()> /// Note that if `from` and `to` both point to the same file, then the file /// will likely get truncated by this operation. /// +/// On success, the total number of bytes copied is returned. +/// /// # Errors /// /// This function will return an error in the following situations, but is not