面试题答案
一键面试trait Transformable {
type Output;
fn transform(&self) -> Self::Output;
}
struct DataHolder<T>
where
T: Transformable,
{
data: T,
}
fn transform_collection<T>(vec: Vec<DataHolder<T>>) -> Vec<T::Output>
where
T: Transformable,
{
vec.into_iter()
.map(|holder| holder.data.transform())
.collect()
}