Implement #[define_opaque] attribute for functions.
This commit is contained in:
@@ -7,6 +7,7 @@ This means
|
||||
|
||||
type Foo<T> = impl std::fmt::Debug;
|
||||
|
||||
#[define_opaque(Foo)]
|
||||
fn foo() -> Foo<u32> {
|
||||
5u32
|
||||
}
|
||||
@@ -19,6 +20,7 @@ is not accepted. If it were accepted, one could create unsound situations like
|
||||
|
||||
type Foo<T> = impl Default;
|
||||
|
||||
#[define_opaque(Foo)]
|
||||
fn foo() -> Foo<u32> {
|
||||
5u32
|
||||
}
|
||||
@@ -36,6 +38,7 @@ Instead you need to make the function generic:
|
||||
|
||||
type Foo<T> = impl std::fmt::Debug;
|
||||
|
||||
#[define_opaque(Foo)]
|
||||
fn foo<U>() -> Foo<U> {
|
||||
5u32
|
||||
}
|
||||
@@ -56,6 +59,7 @@ use std::fmt::Debug;
|
||||
|
||||
type Foo<T: Debug> = impl Debug;
|
||||
|
||||
#[define_opaque(Foo)]
|
||||
fn foo<U: Debug>() -> Foo<U> {
|
||||
Vec::<U>::new()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user