I am playing around with Rust's capnproto library. Because Rust can infer types in some situations, I can do things like this:
let mut message = ::capnp::message::Builder::new_default();
Without having to know the type of message. If I want to pass a reference to message
into a function, I now need to know what message is to let the function know what to expect.
Is there a convenient way to do this in general?
So far I have done the following:
let testing: () = message;
which fails with the compiler error:
error[E0308]: mismatched types
--> src/main.rs:197:18
|
197 | let temp: () = message;
| ^^^^^^^ expected (), found struct `capnp::message::Builder`
But when I type annotate my function as follows:
fn example_fn(message: capnp::message::Builder) {...}
I get an error like:
error[E0243]: wrong number of type arguments: expected 1, found 0
--> src/main.rs:72:32
|
72 | fn dump_capnp_to_file(message: capnp::message::Builder, filename: &str) {
| ^^^^^^^^^^^^^^^^^^^^^^^ expected 1 type argument
error: aborting due to previous error
I'm very new to Rust coming from a C++ background; sorry if this a rookie question!
^^^
point at something important but we can't tell what. – Shepmastervector
instead of avector<int>
— does that help? – Shepmastervector
you mean that 'Builder' is a template and needs further typing information? – JMzance