Merge pull request #4684 from erickt/incoming

core: convert ToStr::to_str to take explicit &self
This commit is contained in:
Brian Anderson 2013-02-04 10:15:02 -08:00
commit 27e1ac5bb9
26 changed files with 88 additions and 72 deletions

View file

@ -18,7 +18,7 @@ pub mod kitty {
}
pub impl cat : ToStr {
pure fn to_str() -> ~str { copy self.name }
pure fn to_str(&self) -> ~str { copy self.name }
}
priv impl cat {

View file

@ -20,7 +20,7 @@ impl Point : ToStr { //~ ERROR implements a method not defined in the trait
Point { x: x, y: y }
}
pure fn to_str() -> ~str {
pure fn to_str(&self) -> ~str {
fmt!("(%f, %f)", self.x, self.y)
}
}

View file

@ -14,5 +14,5 @@ struct S {
impl S: Cmp, ToStr { //~ ERROR: expected `{` but found `,`
fn eq(&&other: S) { false }
fn to_str() -> ~str { ~"hi" }
}
fn to_str(&self) -> ~str { ~"hi" }
}

View file

@ -54,7 +54,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
}
impl cat: ToStr {
pure fn to_str() -> ~str { copy self.name }
pure fn to_str(&self) -> ~str { copy self.name }
}
fn print_out<T: ToStr>(thing: T, expected: ~str) {

View file

@ -28,8 +28,8 @@ enum square {
}
impl square: to_str::ToStr {
pure fn to_str() -> ~str {
match self {
pure fn to_str(&self) -> ~str {
match *self {
bot => { ~"R" }
wall => { ~"#" }
rock => { ~"*" }

View file

@ -110,7 +110,7 @@ impl AsciiArt
// Note that the %s fmt! specifier will not call this automatically.
impl AsciiArt : ToStr
{
pure fn to_str() -> ~str
pure fn to_str(&self) -> ~str
{
// Convert each line into a string.
let lines = do self.lines.map |line| {str::from_chars(*line)};

View file

@ -4,7 +4,7 @@ struct Thingy {
}
impl ToStr for Thingy {
pure fn to_str() -> ~str {
pure fn to_str(&self) -> ~str {
fmt!("{ x: %d, y: %d }", self.x, self.y)
}
}
@ -14,7 +14,7 @@ struct PolymorphicThingy<T> {
}
impl<T:ToStr> ToStr for PolymorphicThingy<T> {
pure fn to_str() -> ~str {
pure fn to_str(&self) -> ~str {
self.x.to_str()
}
}