Guidance on manually implementing Any
, getters etc
#727
-
I have a type that looks like: pub struct PciDeviceVendorLookup<S> {
pub vendor: Option<S>,
pub device: Option<S>,
pub subvendor: Option<S>,
pub subdevice: Option<S>,
} This gets parameterised either on
As such I want to implement impl rune::Any for PciVendorLookup<String> {
fn type_hash() -> rune::Hash {
todo!()
}
}
impl rune::compile::Named for PciVendorLookup<String> {
const BASE_NAME: rune::runtime::RawStr = todo!();
} Unfortunately I can't find any guidance on what to put for Nor can I find anything much on how to implement associated / inherent functions or getters in this case. My proc-macro-fu is very lacking, I tried to figure out what I'm supposed to do that way, but no luck. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I had a read of what the proc-macro generates and derive Any seems to also derive a bunch of other things. Yes So I don't see a way forward on my own here, apart from creating two non-generic structs (but that would be admitting defeat). Any guidance would be appreciated @udoprog. |
Beta Was this translation helpful? Give feedback.
This would primarily be about missing bounds over
S
. We actually have a test case for a generic type usingAny
:rune/crates/rune/src/tests/external_generic.rs
Line 18 in 38de932
It would be better if we added the bounds per trait as-needed instead of requiring that it's present over the whole type, since now it would have to be present for every impl block related to the type.