capnproto-rust icon indicating copy to clipboard operation
capnproto-rust copied to clipboard

bespoke traits that could be replaced with standard traits

Open danieleades opened this issue 3 years ago • 7 comments

i see some bespoke traits which are similar to standard library traits, I was hoping you could comment.

For example, there are ToU16 and FromU16 traits, which seem like they would map precisely to the standard library traits Into<u16> and TryFrom<u16, Error=capnp::NotInSchema> respectively. Is there a reason for not using the standard traits?

  • [x] #336
  • [ ] #337
  • [ ] #340
  • [ ] #355
  • [ ] #349
  • [x] #350
  • [ ] #351

danieleades avatar Nov 14 '22 04:11 danieleades

incidentally, if i were to change the code generation for files like capnpc/src/schema_capnp.rs, how would I regenerate those files?

danieleades avatar Nov 14 '22 05:11 danieleades

Using the standard Into and TryFrom traits makes sense to me. Probably ToU16 and FromU16 were created before the standard traits existed. Note, though, that replacing them would be a breaking change. So I suppose that's another thing that can go into the 0.16.0 release, whenever we do that.

dwrensha avatar Nov 15 '22 14:11 dwrensha

incidentally, if i were to change the code generation for files like capnpc/src/schema_capnp.rs, how would I regenerate those files?

  1. Get the the corresponding .capnp files from the main capnproto repo: https://github.com/capnproto/capnproto/blob/master/c%2B%2B/src/capnp/schema.capnp
  2. build capnpc-rust with cargo build -p capnpc --release
  3. run capnp compile -o./target/release/capnpc-rust [schema file]

dwrensha avatar Nov 15 '22 14:11 dwrensha

starting to collect a few breaking changes. how do you keep track? will you just leave this PR open?

danieleades avatar Nov 15 '22 14:11 danieleades

starting to collect a few breaking changes. how do you keep track? will you just leave the PR open?

danieleades avatar Nov 15 '22 14:11 danieleades

We could add a "version bump" label for issues and PRs.

dwrensha avatar Nov 15 '22 14:11 dwrensha

@dwrensha I notice there's a huge number of structs with new_default constructors. Is there a reason for using this pattern over the built in Default trait?

danieleades avatar Nov 19 '22 13:11 danieleades