about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-06 09:27:59 -0800
committerbors <bors@rust-lang.org>2013-03-06 09:27:59 -0800
commit4b79a58d9d30c09366e562691d50182b335aef6e (patch)
tree6f58a75d27b074adabf091f77e4680888d2a9ff0 /src/libstd
parent67100ddb3519dedf8ab07371a381c7762f9fcc4f (diff)
parent5653fe666dcf35f1139f1b561288fd925d593783 (diff)
downloadrust-4b79a58d9d30c09366e562691d50182b335aef6e.tar.gz
rust-4b79a58d9d30c09366e562691d50182b335aef6e.zip
auto merge of #5252 : nikomatsakis/rust/issue-5087-make-trait-not-impl-self, r=pcwalton
Two changes:

- The first fixes an inconsistency in coherence whereby extension methods were added to the inherent methods table, but only in cross-crate scenarios.  This causes some minor fallout in tests and so forth.  In one case (comm) I added inherent and trait methods so as to avoid the need to import traits like `GenericPort` just to use a port.

- The second makes objects not implement the associated trait, as discussed in #5087.

r? @pcwalton


Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/comm.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs
index 14a37ecbf52..e3437fc57aa 100644
--- a/src/libstd/comm.rs
+++ b/src/libstd/comm.rs
@@ -25,6 +25,27 @@ pub struct DuplexStream<T, U> {
     priv port: Port<U>,
 }
 
+// Allow these methods to be used without import:
+#[cfg(stage1)]
+#[cfg(stage2)]
+pub impl<T:Owned,U:Owned> DuplexStream<T, U> {
+    fn send(x: T) {
+        self.chan.send(x)
+    }
+    fn try_send(x: T) -> bool {
+        self.chan.try_send(x)
+    }
+    fn recv() -> U {
+        self.port.recv()
+    }
+    fn try_recv() -> Option<U> {
+        self.port.try_recv()
+    }
+    pure fn peek() -> bool {
+        self.port.peek()
+    }
+}
+
 impl<T:Owned,U:Owned> GenericChan<T> for DuplexStream<T, U> {
     fn send(&self, x: T) {
         self.chan.send(x)