forked from rust-lang/glacier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
355856c
commit 35b87f5
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
struct A; | ||
struct B; | ||
struct C; | ||
struct D; | ||
struct E; | ||
struct F; | ||
struct G; | ||
|
||
fn foo(a: &A, d: D, e: &E, g: G) {} | ||
|
||
fn main() { | ||
foo(&&A, B, C, D, E, F, G); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pub type Yes = extern "sysv64" fn(&'static u8) -> !; | ||
|
||
fn main() { | ||
unsafe { | ||
let yes = &6 as *const _ as *const Yes; | ||
core::arch::asm!("call {}", in(reg) yes, options(noreturn)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::ops::Sub; | ||
|
||
trait Vector2 { | ||
type ScalarType; | ||
fn from_values(x: Self::ScalarType, y: Self::ScalarType) -> Self | ||
where Self: Sized; | ||
fn x(&self) -> Self::ScalarType; | ||
fn y(&self) -> Self::ScalarType; | ||
} | ||
|
||
impl<T> Sub for dyn Vector2<ScalarType=T> | ||
where T: Sub<Output=T>, | ||
(dyn Vector2<ScalarType=T>): Sized{ | ||
type Output = dyn Vector2<ScalarType=T>; | ||
fn sub(self, rhs: Self) -> Self::Output { | ||
Self::from_values(self.x()-rhs.x(), self.y() - rhs.y()) | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![feature(core_intrinsics)] | ||
use std::intrinsics::wrapping_add; | ||
|
||
#[derive(Clone, Copy)] | ||
struct WrapInt8 { | ||
value: u8 | ||
} | ||
|
||
impl std::ops::Add for WrapInt8 { | ||
type Output = WrapInt8; | ||
fn add(self, other: WrapInt8) -> WrapInt8 { | ||
wrapping_add(self, other) | ||
} | ||
} | ||
|
||
fn main() { | ||
let p = WrapInt8 { value: 123 }; | ||
let q = WrapInt8 { value: 234 }; | ||
println!("{}", (p + q).value); | ||
} |