We have a trait like
/// A source of data of some specified kind.
pub trait DataSource<T: Kind>: DataSourceBase {
/// Returns the value associated with this kind.
fn get_values(&self) -> T::Values;
/// Same as `get_values` but only available for kinds with only one value.
fn get_value(&self) -> Option<T> where T: Kind<Values=Option<T>> {
self.get_values()
}
}
But if a type is both DataSource<Title>
and DataSource<Url>
, then we can't call foo.get_value()
. The only alternative seems to be <Foo as DataSource<Title>>::get_value(&foo)
which kinda sucks because it forces us to write the type (Foo
) and add in the &
. Any way to not have to do that? (Really wish <foo as DataSource<Title>>.get_value()
was a thing, but anyway...)
We guess we could do (&foo as &dyn DataSource<Title>).get_value()
but not sure if the compiler can optimize that.