Implement #[define_opaque]
attribute for functions.
This commit is contained in:
parent
540565e5b9
commit
d9de94001a
1 changed files with 14 additions and 16 deletions
|
@ -2,23 +2,21 @@
|
||||||
|
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
mod helper {
|
pub trait T {
|
||||||
pub trait T {
|
type Item;
|
||||||
type Item;
|
}
|
||||||
}
|
|
||||||
|
pub type Alias<'a> = impl T<Item = &'a ()>;
|
||||||
pub type Alias<'a> = impl T<Item = &'a ()>;
|
|
||||||
|
struct S;
|
||||||
struct S;
|
impl<'a> T for &'a S {
|
||||||
impl<'a> T for &'a S {
|
type Item = &'a ();
|
||||||
type Item = &'a ();
|
}
|
||||||
}
|
|
||||||
|
#[define_opaque(Alias)]
|
||||||
pub fn filter_positive<'a>() -> Alias<'a> {
|
pub fn filter_positive<'a>() -> Alias<'a> {
|
||||||
&S
|
&S
|
||||||
}
|
|
||||||
}
|
}
|
||||||
use helper::*;
|
|
||||||
|
|
||||||
fn with_positive(fun: impl Fn(Alias<'_>)) {
|
fn with_positive(fun: impl Fn(Alias<'_>)) {
|
||||||
fun(filter_positive());
|
fun(filter_positive());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue