Skip to content

[Question]How to extract generic type values #491

Closed
@SteveLauC

Description

@SteveLauC

Hi! Thanks for this amazing project!

I would like to know how I can extract the value of a generic type from its Reader type.

For example, for the following Entry type:

struct Entry(K, V) {
  key @0 :K;
  value @1 :V;
}

I want to implement From<entry::Reader<'_, K, V> for (K, V):

impl<K, V> From<entry::Reader<'_, K, V>> for (K, V)
where
    K: capnp::traits::Owned,
    V: capnp::traits::Owned,
{
    fn from(value: crate::map_capnp::entry::Reader<'_, K, V>) -> Self {
        let key: <K as Owned>::Reader = value.get_key().unwrap();
        let value: <V as Owned>::Reader = value.get_value().unwrap();

        
        todo!()
    }
}

As you can see, I can access their Reader types, but how can I extra their values, i.e., values of type K and V, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions