I tried using saffer-ffi 0.1.13 for generating C headers. Following the sample works without a problem. However, when attempting to add for the following function, it fails with errors for the code below
pub fn byte_pair_encode(piece: &[u8], ranks: &HashMap<Vec<u8>, Rank>) -> Vec<Rank> {
if piece.len() == 1 {
return vec![ranks[piece]];
}
_byte_pair_merge(ranks, piece)
.windows(2)
.map(|part| ranks[&piece[part[0].0..part[1].0]])
.collect()
}
The error message
type mismatch resolving `<OpaqueLayout_<PhantomData<&[u8]>> as CType>::OPAQUE_KIND == Concrete`
required for `&[u8]` to implement `ConcreteReprC`
the trait bound `HashMap<std::vec::Vec<u8>, u32, BuildHasherDefault<FxHasher>>: ReprC` is not satisfied
the trait `ReprC` is implemented for `HashMap<K, V>`
required for `&HashMap<std::vec::Vec<u8>, u32, BuildHasherDefault<FxHasher>>` to implement `ReprC`
required for `&HashMap<std::vec::Vec<u8>, u32, BuildHasherDefault<FxHasher>>` to implement `ConcreteReprC`
type mismatch resolving `<OpaqueLayout_<PhantomData<Vec<u32>>> as CType>::OPAQUE_KIND == Concrete`
required for `std::vec::Vec<u32>` to implement `ConcreteReprC`
I kind of understand the trait ReprC
is implemented for HashMap<K, V>
, as the actual type K is Vec<?>, and V u32. But when checking the custom type page about hashmap, that page says Coming soon.
How can I solve those errors? Thanks.