I think what I want is specialization in Rust. But I'm not sure if that's actually what I want. E.g. I want to be able to define some method. But then if certain conditions apply define a different, more efficient method with the same signature. That's... specialization right?
Ah, so I was more thinking along the lines of having more specific impls for specific trait bounds. E.g. impl<T: AsyncRead> Socket<T> { from_reader(t: T) -> Result<Self>; } impl Socket<File> { from_reader(t: File) -> Result<Self>; } #2 could likely be more optimized
-
-
This might work for concrete types already (haven't checked, believe there's some cases in which it works). But I believe you can't specify more specific trait bounds for T that's not a concrete type.
-
My theoretical knowledge around this stuff is still... not great -- I feel like I know what I want, but not confident in which constraints currently exist.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.