Skip to content

Use associated types in Doublets trait  #5

@uselessgoddess

Description

@uselessgoddess

Use Doublets<Item = T> instead of Doublets<T>

This is idiomatically more correct. For example – AsRef and Deref:

let string = "hello".to_string();
// we want `AsRef<[u8]>`
let bytes: &[u8] = string.as_ref();
// we want `AsRef<str>`
let str: &str = string.as_ref();
let string = "hello".to_string();
let str = &*string; // we are given `str`

This will also make generic storing doublets than easier.

struct Wrapper<T, D: Doublets<T>> {
    doublets: D,
    _marker: PhantomData<T>,
}
struct Wrapper<D: Doublets> {
    doublets: D,
}
// `T` is `D::Item`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions