This repository was 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.
- Loading branch information
1 parent
95f5628
commit 3562248
Showing
2 changed files
with
34 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,29 @@ | ||
use std::marker::PhantomData; | ||
|
||
pub struct NfaBuilder<'brand> { | ||
brand: PhantomData<&'brand mut &'brand mut ()>, | ||
} | ||
|
||
impl NfaBuilder<'_> { | ||
pub fn with<R, F: FnOnce(NfaBuilder<'_>) -> R>(f: F) -> R { | ||
Brand::with(|brand| { | ||
// This should be using NfaBuilder instead of Self becuase they have diffrent lifetime constraints | ||
f(Self { | ||
brand: brand.lt, | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct Brand<'brand> { | ||
lt: PhantomData<&'brand mut &'brand mut ()>, | ||
} | ||
|
||
impl Brand<'_> { | ||
pub fn with<R, F: FnOnce(Brand<'_>) -> R>(f: F) -> R { | ||
f(Self { lt: PhantomData }) | ||
} | ||
} | ||
|
||
pub 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,5 @@ | ||
#![crate_type = "lib"] | ||
#![feature(async_fn_in_trait)] | ||
trait T { | ||
async fn foo(); | ||
} |