Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use associated types in Doublets trait #5

Open
uselessgoddess opened this issue Jul 31, 2022 · 0 comments
Open

Use associated types in Doublets trait #5

uselessgoddess opened this issue Jul 31, 2022 · 0 comments
Labels
Issue:Incomplete Issue: this is incomplete

Comments

@uselessgoddess
Copy link
Member

uselessgoddess commented Jul 31, 2022

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`
@uselessgoddess uselessgoddess added the Issue:Incomplete Issue: this is incomplete label Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue:Incomplete Issue: this is incomplete
Projects
None yet
Development

No branches or pull requests

1 participant