Hi Stewart, I agree that it can sometimes be cumbersome to construct values in capnproto-rust. Two things that we could work on to improve this situation are:
1. For the case when your values are constants, we could implement support for pointer-field constants, allowing you to "construct" the values in schema files. https://capnproto.org/language.html#constants 2. We could use macros, as in https://github.com/bfops/capnpc-macros (Note that I haven't actually tried out this particular project, but the approach seems promising.) Responses to your specific code issues are inline below. On Fri, Sep 16, 2016 at 5:55 PM, stewart mackenzie <[email protected]> wrote: > > the code: > > let mut ip = out_ip.init_root::<list_list_list_text::Builder>(); > for file in mock_commands { > let mut line_count: u32 = 0; > let mut list_0 = ip.init_list(file.len() as u32); > If I change this line to let mut list_0 = ip.borrow().init_list(file.len() as u32); then your example typechecks. > How does one add > > #[derive(Copy, Clone)] > > to contract_capnp::list_list_list_text::Builder<'_'> ? > > You can't without sacrificing memory safety. You should think of a Builder as a mutable reference, and mutable references in Rust cannot be copied, as that would allow aliasing. I wrote a blog post about this: https://dwrensha.github.io/capnproto-rust/2014/12/27/custom-mutable-references.html - David -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/capnproto.
