Merge pull request #2435 from smanilov/patch-19
Add opaque type attributes
This commit is contained in:
commit
08e9bce01c
|
|
@ -13,13 +13,16 @@ it can work across functions and function bodies.
|
||||||
To help explain how it works, let's consider an example.
|
To help explain how it works, let's consider an example.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
mod m {
|
mod m {
|
||||||
pub type Seq<T> = impl IntoIterator<Item = T>;
|
pub type Seq<T> = impl IntoIterator<Item = T>;
|
||||||
|
|
||||||
|
#[define_opaque(Seq)]
|
||||||
pub fn produce_singleton<T>(t: T) -> Seq<T> {
|
pub fn produce_singleton<T>(t: T) -> Seq<T> {
|
||||||
vec![t]
|
vec![t]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[define_opaque(Seq)]
|
||||||
pub fn produce_doubleton<T>(t: T, u: T) -> Seq<T> {
|
pub fn produce_doubleton<T>(t: T, u: T) -> Seq<T> {
|
||||||
vec![t, u]
|
vec![t, u]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue