Skip to content

Confusing example on covariance #48

Description

@AlanStokes

I'm not sure if this is an issue or not, but I can't get my head round it.

I have a copy of the first printing, and on page 16, first paragraph we have a couple of sentences explaining that &'a T is covariant in 'a, which I get. But then there is this sentence:

&'a T is also covariant in T, so you can pass a &Vec<&' static str> to a function that takes &Vec<'a str>.

I think I know what the first bit means, but I don't understand how the example relates to it. It shows that &Vec<T> is covariant in T, but that's not obviously the same thing.

Or is T here intended to be Vec<&'a str>? If so, we have two unrelated uses of 'a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions