first commit
This commit is contained in:
commit
4cd2267497
10 changed files with 644 additions and 0 deletions
8
examples/borrow.rs
Normal file
8
examples/borrow.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#![allow(unused)]
|
||||
|
||||
fn main() {
|
||||
let mut a = 5;
|
||||
let b = &mut a;
|
||||
let x = &a;
|
||||
println!("{}", b);
|
||||
}
|
||||
13
examples/coinductive.rs
Normal file
13
examples/coinductive.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#![allow(unused)]
|
||||
|
||||
enum List<T> {
|
||||
Nil,
|
||||
Cons(T, Box<List<T>>),
|
||||
}
|
||||
|
||||
fn is_send(x: impl Send) {}
|
||||
|
||||
fn main() {
|
||||
let x = 3;
|
||||
is_send(List::Cons(&mut x as *mut _, Box::new(List::Nil)))
|
||||
}
|
||||
5
examples/local.rs
Normal file
5
examples/local.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
let x = 3;
|
||||
println!("{}", x + y);
|
||||
}
|
||||
|
||||
1
examples/nora.rs
Normal file
1
examples/nora.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
fn main() {}
|
||||
26
examples/private_field_deref.rs
Normal file
26
examples/private_field_deref.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
mod private {
|
||||
pub struct Foo {
|
||||
field: i32,
|
||||
bar: Bar,
|
||||
}
|
||||
|
||||
pub struct Bar {
|
||||
pub field: u32,
|
||||
}
|
||||
|
||||
impl std::ops::Deref for Foo {
|
||||
type Target = Bar;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.bar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use private::Foo;
|
||||
|
||||
fn example(f: Foo) {
|
||||
let a: i32 = f.field;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
4
examples/traits.rs
Normal file
4
examples/traits.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
let _: &dyn Eq = &123;
|
||||
let _: &dyn Iterator = &vec![123].into_iter();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue