View gist:43298cf71b4b1de0dae1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait AsRef<T: ?Sized> { | |
fn convert_as_ref(&self) -> &T; | |
} | |
trait Into<T> { | |
fn convert_into(self) -> T; | |
} | |
trait From<T> { | |
fn from(T) -> Self; |
View gist:d4355fe915a7bdaeadeb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As lifts over Deref | |
impl<D: ?Sized + Deref, U: ?Sized> AsRef<U> for D where D::Target: AsRef<U> { | |
fn as_ref(&self) -> &U { | |
self.deref().as_ref() | |
} | |
} |
View gist:d53613d1c0cce1297bf1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Rand<Distribution> { | |
type Stream: RandStream<T>; | |
fn rand(dist: Distribution) -> Stream; | |
} | |
trait RandStream<T> { | |
fn next<R: Rng>(&self, rng: &mut R) -> T; | |
} | |
impl Rand<Range<u32, u32>> for u32 { |
View gist:1dbb8a06d3f3d966126e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Rand<Rng, Distribution> { | |
type Iter: Iterator<Item = Self>; | |
fn rand(rng: Rng, dist: Distribution) -> Iter; | |
} |
View gist:9f29e9edae931b87a84d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn nonparametric<T: 'static>(t: T) { | |
let b: Box<Any> = box t; | |
match b.downcast::<SomeConcreteType>() { | |
... | |
} | |
} |
View gist:fac0804d0560913111a8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait CoerceFrom<T> { | |
fn coerce_from(T) -> Self; | |
} | |
trait Coerce { | |
fn coerce<T>(self) -> T where T: CoerceFrom<Self>; | |
} | |
impl<T> Coerce for T { | |
fn coerce<U: CoerceFrom<T>>(self) -> U { |
View path-strawman.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Types: Path and path (later being unsized) | |
impl Deref<path> for Path { ... } | |
fn new<T: BytesContainer>(path: T) -> Path | |
fn dir(&self) -> &path | |
impl Path { | |
fn new<T: BytesContainer>(path: T) -> Path |
View gist:bf84ef392ee6512aada3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn nth(&mut self, mut n: uint) -> Option<A> { | |
for x in *self { | |
if n == 0 { return Some(x) } | |
n -= 1; | |
} | |
None | |
} | |
error: cannot borrow immutable local variable `self` as mutable | |
for x in *self { |
View gist:408b84b7a9897cc5fd8b
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'test-addrinfo.0.rs' | |
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-pc-windows-gnu" | |
%str_slice = type { i8*, i64 } | |
%"struct.core::intrinsics::TypeId<[]>[#3]" = type { i64 } | |
%"struct.task::Ops<[]>" = type { %"struct.rustrt::mutex::NativeMutex<[]>[#9]", i8, { i64, i64 }, i64 } | |
%"struct.rustrt::mutex::NativeMutex<[]>[#9]" = type { %"struct.rustrt::mutex::StaticNativeMutex<[]>[#9]", i8 } | |
%"struct.rustrt::mutex::StaticNativeMutex<[]>[#9]" = type { %"struct.rustrt::mutex::imp::Mutex<[]>[#9]" } | |
%"struct.rustrt::mutex::imp::Mutex<[]>[#9]" = type { %"struct.core::atomic::AtomicUint<[]>[#3]", %"struct.core::atomic::AtomicUint<[]>[#3]" } |
View gist:907ad956a1f653b3ff2e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
failures: | |
---- io::net::addrinfo::test::dns_smoke_test stdout ---- | |
task 'io::net::addrinfo::test::dns_smoke_test' panicked at 'called `Result::unwrap()` on an `Err` value: OS Error 0: The operation completed successfully. | |
', C:\msys64\home\aturon\rust\src\libcore\result.rs:788 |
NewerOlder