From 99017f82b6e41ed283199b88ddfc0990bb95d696 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 31 Dec 2014 15:45:13 -0500 Subject: use assoc types in binop traits --- src/libsyntax/codemap.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/codemap.rs') diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 5eac6546c6b..eb011faa55d 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -53,13 +53,17 @@ impl Pos for BytePos { fn to_uint(&self) -> uint { let BytePos(n) = *self; n as uint } } -impl Add for BytePos { +impl Add for BytePos { + type Output = BytePos; + fn add(self, rhs: BytePos) -> BytePos { BytePos((self.to_uint() + rhs.to_uint()) as u32) } } -impl Sub for BytePos { +impl Sub for BytePos { + type Output = BytePos; + fn sub(self, rhs: BytePos) -> BytePos { BytePos((self.to_uint() - rhs.to_uint()) as u32) } @@ -70,13 +74,17 @@ impl Pos for CharPos { fn to_uint(&self) -> uint { let CharPos(n) = *self; n } } -impl Add for CharPos { +impl Add for CharPos { + type Output = CharPos; + fn add(self, rhs: CharPos) -> CharPos { CharPos(self.to_uint() + rhs.to_uint()) } } -impl Sub for CharPos { +impl Sub for CharPos { + type Output = CharPos; + fn sub(self, rhs: CharPos) -> CharPos { CharPos(self.to_uint() - rhs.to_uint()) } -- cgit 1.4.1-3-g733a5