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
se std::ops::Deref; | |
pub trait Data: Deref<Target = Self::Item> { | |
type Item; | |
} | |
fn main() { | |
} |
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
pub trait Even { | |
fn say(&self); | |
} | |
impl <'a, E: Even> Even for &'a mut E { | |
fn say(&self) { } | |
} | |
pub trait Odd { | |
fn say(&self); |
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
pub struct ReaderRef<'a, R> { | |
priv reader: &'a mut R | |
} | |
impl <'a, R: Reader> ReaderRef<'a, R> { | |
pub fn new<'a>(reader: &'a mut R) -> ReaderRef<'a, R> { | |
ReaderRef { | |
reader: reader | |
} | |
} |
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 SomeTrait { } | |
struct SomeStruct; | |
impl SomeTrait for SomeStruct { } | |
fn foo<T: SomeTrait>(_: T) { } | |
fn main() { | |
// This works fine |
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 T1 { } | |
trait T2 { } | |
struct S1; | |
impl T1 for S1 { } | |
impl <S: T2> T1 for S { } |
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
make check-stage1-rustpkg | |
cfg: build triple x86_64-unknown-linux-gnu | |
cfg: host triples x86_64-unknown-linux-gnu | |
cfg: target triples x86_64-unknown-linux-gnu | |
cfg: enabling more debugging (CFG_ENABLE_DEBUG) | |
cfg: host for x86_64-unknown-linux-gnu is x86_64 | |
cfg: os for x86_64-unknown-linux-gnu is unknown-linux-gnu | |
cfg: using gcc | |
cfg: no pandoc found, omitting docs | |
cfg: no node found, omitting docs |
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
/* | |
Here is my goal: I'd like to have a struct that basically operates as a state | |
machine. I'd like the current state to be represented as an enum which contains | |
a non-copyable value inside it related to the current state. When proessing each | |
state, I'd like to deconstruct the state, pull out the value inside it, and then | |
put a new value into a new state and transition to that state. In the code | |
I'm actually working on, I'm not allocating on the heap on state transitions, | |
but I think this is more readable for this question. Anyway, is there a better | |
way to do that than by using this next_state() function that I've cooked up? | |
My first attempt was to directly match on the state value, but, I got errors |
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 GetBuffer<'self> { | |
fn get(&self) -> &'self [u8]; | |
} | |
// This works | |
struct Buff1<'self> { | |
b: &'self [u8] | |
} | |
impl <'self> GetBuffer<'self> for Buff1<'self> { | |
fn get(&self) -> &'self [u8] { self.b } |
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
use std::hash; | |
use std::hash::Streaming; | |
// I believe that this pretty much the same thing as hash_crate_independent() in ty.rs | |
// for a ty_struct on a 64-bit platform | |
fn hash_struct(local_hash: &str, node: u64) -> u64 { | |
let mut state = hash::default_state(); | |
state.input([18]); | |
state.input(local_hash.as_bytes()); | |
do node.iter_bytes(true) |bytes| { state.input(bytes); true }; |
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
struct Struct<'self, B> { | |
val: B | |
} | |
impl <'self, B: MutableVector<'self, u8>> Struct<'self, B> { | |
} |
NewerOlder