Given the following:
use std::fmt::Debug; #[derive(Debug)] enum A<T: Debug> { X, Y(T), } #[derive(Debug)] struct B; type C = A<B>;
I can use it like:
fn main() { let val0 = A::X::<B>; let val1 = A::Y::<B>(B); println!("{:?}\t{:?}", val0, val1); }
But then for more than one common parameter (or if A , B , etc. were much longer than the names, and then for an alias, I tried the following, but it does not compile:
fn main() { let val0 = C::X; let val1 = C::Y(B); println!("{:?}\t{:?}", val0, val1); }
with mistakes:
src/main.rs:656:16: 656:20 error: no associated item named `X` found for type `A<B>` in the current scope src/main.rs:656 let val0 = C::X; ^~~~ src/main.rs:657:16: 657:20 error: no associated item named `Y` found for type `A<B>` in the current scope src/main.rs:657 let val1 = C::Y(B);
As also noted, I cannot use use to solve the problem. Is there any way around this (because typing it all seems cumbersome)?
rustc --version rustc 1.9.0 (e4e8b6668 2016-05-18)
source share