forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Lukas Markeffsky
committed
Feb 5, 2023
1 parent
9d11084
commit e2a1a2a
Showing
1 changed file
with
42 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,42 @@ | ||
// build-pass | ||
// compile-flags: -C opt-level=3 | ||
|
||
#![crate_type = "lib"] | ||
|
||
pub trait Archive { | ||
type Archived; | ||
type Resolver; | ||
|
||
fn resolve(resolver: Self::Resolver, out: *mut Self::Archived); | ||
} | ||
|
||
pub type Archived<T> = <T as Archive>::Archived; | ||
pub type Resolver<T> = <T as Archive>::Resolver; | ||
|
||
pub struct Record<'a> { | ||
_payload: &'a [u8], | ||
} | ||
|
||
pub struct ArchivedRecord<'a> | ||
where | ||
&'a [u8]: Archive, | ||
{ | ||
_payload: Archived<&'a [u8]>, | ||
} | ||
|
||
pub struct RecordResolver<'a> | ||
where | ||
&'a [u8]: Archive, | ||
{ | ||
_payload: Resolver<&'a [u8]>, | ||
} | ||
|
||
impl<'a> Archive for Record<'a> | ||
where | ||
&'a [u8]: Archive, | ||
{ | ||
type Archived = ArchivedRecord<'a>; | ||
type Resolver = RecordResolver<'a>; | ||
|
||
fn resolve(_resolver: Self::Resolver, _out: *mut Self::Archived) {} | ||
} |