Comments (3)
You don't need dynamic dispatch.
#![feature(specialization)]
trait Lookup: Sized {
type Collection: Collection<Self>;
}
impl<T> Lookup for T {
default type Collection = Vec<T>;
}
impl<T: Hash> Lookup for T {
type Collection = HashSet<T>;
}
struct Wrapper<T: Lookup> {
information: T::Collection,
}
from rfcs.
True, thank you. Doable once (if) Impl specialization arives then. It is quite verbose, but I can see the advantage of that. On the other hand, the approach ^ could be treated as a syntactic sugar ?
from rfcs.
the approach ^ could be treated as a syntactic sugar ?
At least the syntax proposed in OP is impossible, since without a concrete T
you don't know the exact type of self.information
and thus can't call any useful method. You still need that Collection
trait and with that struct specialization syntax you can't associate the trait Collection
to the member information
anywhere.
from rfcs.
Related Issues (20)
- Generate an automatic implementation of TryFrom and Into for C-style enums HOT 5
- Redesign `Arc` API HOT 5
- Float rounding with specified digits HOT 4
- Refactor shared methods of `f32` and `f64` into new `Float` trait HOT 3
- Enable `Self = F` in generic `where` clause HOT 1
- Named opt-in trait impls HOT 2
- https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints uses `-` HOT 1
- new type of enum HOT 8
- Pre-RFC: Add a built-in support for totality (or non-panicking/aborting) asserting HOT 6
- Potential Compiler Optimization Issue with &Vec<Vec<T>> vs &[Vec<T>]? HOT 1
- Discussion/Pre-RFC/ACP: Unify privately constructed ("protected") ZSTs in std
- Create a struct similar to std::fs::File for directories HOT 2
- Converging let else HOT 1
- Conditional visibility: for integration testing purpose. HOT 1
- Enum of named structs boilerplate HOT 2
- [moved] Redefine `CARGO_TARGET_DIR` to be only an artifacts directory HOT 3
- Allow opting out of specific parts of core crate (e.g. core::fmt) HOT 11
- First-class compile time type manipulation HOT 4
- `move` `Copy` values HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rfcs.