You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is rather unexpected as the documentation doesn't say so and the usual convention for get method of collections is to return an Option<T> for in invalid index/key/etc.
Would it make sense to (1) change the prototype of capnp::struct_list::Reader::get to return an option and maybe (2) implement the Index trait with the old panicking behavior as done for slices in std?
I am willing to provide the PR, I am just unsure of what non backward compatible change are deemed acceptable.
The text was updated successfully, but these errors were encountered:
We can't use std::ops::Index, because its index() method returns a reference, which we generally can't do because we may need to swap bytes of the value to account for endianness (in the case of primitive_list).
We can't use std::ops::Index, because its index() method returns a reference, which we generally can't do because we may need to swap bytes of the value to account for endianness (in the case of primitive_list).
Right, that's unfortunate. That being said, I am more interested in having a non-panicking version of get methods.
Hello!
Currently
capnp::struct_list::Reader::get
can panic if the index is out of bounds because of an assertion at https://docs.capnproto-rust.org/src/capnp/struct_list.rs.html#84This is rather unexpected as the documentation doesn't say so and the usual convention for
get
method of collections is to return anOption<T>
for in invalid index/key/etc.Would it make sense to (1) change the prototype of
capnp::struct_list::Reader::get
to return an option and maybe (2) implement theIndex
trait with the old panicking behavior as done for slices in std?I am willing to provide the PR, I am just unsure of what non backward compatible change are deemed acceptable.
The text was updated successfully, but these errors were encountered: