3 ms·
Good question. Technically, ToOwned counts: pub trait ToOwned { type Owned: Borrow<Self>; fn clone_into(&self, target: &mut Self::Owned) { ... } }
by sciolizer 2y ago
Good question. Technically, ToOwned counts:
pub trait ToOwned {
type Owned: Borrow<Self>;
fn clone_into(&self, target: &mut Self::Owned) { ... }
}
Here the `Owned` is technically an input to `clone_into`, but of course semantically it's still an output.
A more subtle one is `StreamExt`:
pub trait StreamExt: Stream {
type Item;
fn map<T, F>(self, f: F) -> Map<Self, F>
where F: FnMut(Self::Item) -> T,
Self: Sized { ... }
}
Here, the associated type `Item` is the input to the mapping function, and since the mapping function is an input to the map function, it is an input-to-an-input - which basically makes it an output. i.e. the stream "outputs" the items into the mapping function. (aka two contravariants make a covariant).
I couldn't find any more direct examples.