This repository has been archived by the owner on May 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
- Loading branch information
Showing
5 changed files
with
106 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,21 @@ | ||
trait ColumnOutput<'a> { | ||
type Output; | ||
} | ||
|
||
struct C {} | ||
|
||
impl<'a> ColumnOutput<'a> for C { | ||
type Output = u64; | ||
} | ||
|
||
fn calc<'a, O, F>(f: F) | ||
where | ||
O: ColumnOutput<'a>, | ||
F: Fn(<O as ColumnOutput>::Output) -> u64, | ||
{ | ||
f(vec![].pop().unwrap()); | ||
} | ||
|
||
fn main() { | ||
calc::<C, _>(|_| unimplemented!()); | ||
} |
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,9 @@ | ||
pub struct Header<'a> { | ||
pub value: &'a [u8], | ||
} | ||
|
||
pub fn test() { | ||
let headers = [Header{value: &[]}; 128]; | ||
} | ||
|
||
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,32 @@ | ||
use std::marker::PhantomData; | ||
|
||
struct FsmBuilder<TFsm> { | ||
_fsm: PhantomData<TFsm>, | ||
} | ||
|
||
impl<TFsm> FsmBuilder<TFsm> { | ||
fn state(&mut self) -> FsmStateBuilder<TFsm> { | ||
todo!() | ||
} | ||
} | ||
|
||
struct FsmStateBuilder<TFsm> { | ||
_state: PhantomData<TFsm>, | ||
} | ||
|
||
impl<TFsm> FsmStateBuilder<TFsm> { | ||
fn on_entry<TAction: Fn(&mut StateContext<'_, TFsm>)>(&self, _action: TAction) {} | ||
} | ||
|
||
trait Fsm { | ||
type Context; | ||
} | ||
|
||
struct StateContext<'a, TFsm: Fsm> { | ||
context: &'a mut TFsm::Context, | ||
} | ||
|
||
fn main() { | ||
let mut builder: FsmBuilder<usize> = todo!(); | ||
builder.state().on_entry(|_| {}); | ||
} |
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 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(generic_associated_types)] | ||
|
||
struct E {} | ||
|
||
trait TestMut { | ||
type Output<'a>; | ||
fn test_mut(&mut self) -> Self::Output<'static>; | ||
} | ||
|
||
impl TestMut for E { | ||
type Output<'a> = usize; | ||
fn test_mut(&mut self) -> Self::Output<'static> { | ||
todo!() | ||
} | ||
} | ||
|
||
fn test_simpler(_: impl TestMut<Output = usize>) {} | ||
|
||
fn main() { | ||
test_simpler(E {}); | ||
} |
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 @@ | ||
#!/bin/bash | ||
|
||
rustc --crate-type=proc-macro - << 'EOF' | ||
extern crate proc_macro; | ||
use proc_macro::TokenStream; | ||
#[proc_macro_attribute] | ||
pub fn mac(_attrs: TokenStream, input: TokenStream) -> TokenStream { | ||
input | ||
} | ||
EOF | ||
|
||
rustc --extern mac=$(ls librust_out.*) - << 'EOF' | ||
pub trait Crash { | ||
#[mac::mac] | ||
fn one(s: () { | ||
} | ||
fn two(); | ||
} | ||
fn main () {} | ||
EOF |