diff --git a/capnp-futures/test/test.rs b/capnp-futures/test/test.rs index 557069999..91410d66f 100644 --- a/capnp-futures/test/test.rs +++ b/capnp-futures/test/test.rs @@ -114,7 +114,7 @@ mod tests { let io = futures::future::join(done_reading, write_queue.map(|_| ())); - let mut m = capnp::message::Builder::new_default(); + let mut m = capnp::message::Builder::default(); populate_address_book(m.init_root()); spawner.spawn_local(sender.send(m).map(|_| ())).unwrap(); @@ -153,7 +153,7 @@ mod tests { #[test] fn single_segment() { - fill_and_send_message(capnp::message::Builder::new_default()); + fill_and_send_message(capnp::message::Builder::default()); } #[test] @@ -168,7 +168,7 @@ mod tests { fn static_lifetime_not_required_funcs() { let (mut write, mut read) = async_byte_channel::channel(); let _ = serialize::try_read_message(&mut read, message::ReaderOptions::default()); - let _ = serialize::write_message(&mut write, message::Builder::new_default()); + let _ = serialize::write_message(&mut write, message::Builder::default()); } #[test] diff --git a/capnp-rpc/src/broken.rs b/capnp-rpc/src/broken.rs index 980ad4868..139af8f0d 100644 --- a/capnp-rpc/src/broken.rs +++ b/capnp-rpc/src/broken.rs @@ -59,7 +59,7 @@ impl Request { pub fn new(error: Error, _size_hint: Option<::capnp::MessageSize>) -> Self { Self { error, - message: ::capnp::message::Builder::new_default(), + message: ::capnp::message::Builder::default(), cap_table: Vec::new(), } } diff --git a/capnp-rpc/src/local.rs b/capnp-rpc/src/local.rs index 50ac0d128..17d1f14be 100644 --- a/capnp-rpc/src/local.rs +++ b/capnp-rpc/src/local.rs @@ -90,7 +90,7 @@ struct Results { impl Results { fn new(fulfiller: oneshot::Sender>) -> Self { Self { - message: Some(::capnp::message::Builder::new_default()), + message: Some(::capnp::message::Builder::default()), cap_table: Vec::new(), results_done_fulfiller: Some(fulfiller), } @@ -191,7 +191,7 @@ impl Request { client: Box, ) -> Self { Self { - message: message::Builder::new_default(), + message: message::Builder::default(), cap_table: Vec::new(), interface_id, method_id, diff --git a/capnp-rpc/src/rpc.rs b/capnp-rpc/src/rpc.rs index 1ed92b3e3..11dd361d0 100644 --- a/capnp-rpc/src/rpc.rs +++ b/capnp-rpc/src/rpc.rs @@ -2214,7 +2214,7 @@ where } _ => { self.variant = Some(ResultsVariant::LocallyRedirected( - ::capnp::message::Builder::new_default(), + ::capnp::message::Builder::default(), Vec::new(), )); } diff --git a/capnp-rpc/src/twoparty.rs b/capnp-rpc/src/twoparty.rs index ced1e68cf..54582c6d4 100644 --- a/capnp-rpc/src/twoparty.rs +++ b/capnp-rpc/src/twoparty.rs @@ -152,7 +152,7 @@ where _first_segment_word_size: u32, ) -> Box { Box::new(OutgoingMessage { - message: ::capnp::message::Builder::new_default(), + message: ::capnp::message::Builder::default(), sender: self.inner.borrow().sender.clone(), }) } diff --git a/capnp-rpc/test/test.rs b/capnp-rpc/test/test.rs index b28dec17b..3df7167b7 100644 --- a/capnp-rpc/test/test.rs +++ b/capnp-rpc/test/test.rs @@ -354,7 +354,7 @@ fn pipelining_return_null() { #[test] fn null_capability() { - let mut message = ::capnp::message::Builder::new_default(); + let mut message = ::capnp::message::Builder::default(); let root: crate::test_capnp::test_all_types::Builder = message.get_root().unwrap(); // In capnproto-c++, this would return a BrokenCap. Here, it returns a decode error. diff --git a/capnp/fuzz/fuzzers/test_all_types.rs b/capnp/fuzz/fuzzers/test_all_types.rs index d6a29d870..a90907019 100644 --- a/capnp/fuzz/fuzzers/test_all_types.rs +++ b/capnp/fuzz/fuzzers/test_all_types.rs @@ -129,7 +129,7 @@ fn try_go(mut data: &[u8]) -> ::capnp::Result<()> { root.total_size()?; traverse(root)?; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); message.set_root(root)?; assert_equal( diff --git a/capnp/src/any_pointer.rs b/capnp/src/any_pointer.rs index 2b2bbc2db..13959a829 100644 --- a/capnp/src/any_pointer.rs +++ b/capnp/src/any_pointer.rs @@ -247,7 +247,7 @@ impl crate::capability::FromTypelessPipeline for Pipeline { #[test] fn init_clears_value() { - let mut message = crate::message::Builder::new_default(); + let mut message = crate::message::Builder::default(); { let root: crate::any_pointer::Builder = message.init_root(); let mut list: crate::primitive_list::Builder = root.initn_as(10); diff --git a/capnp/src/message.rs b/capnp/src/message.rs index c30234051..5efeb7887 100644 --- a/capnp/src/message.rs +++ b/capnp/src/message.rs @@ -51,7 +51,7 @@ //! use capnp::message::{self, TypedBuilder, TypedReader}; //! //! fn main() { -//! let mut builder = TypedBuilder::::new_default(); +//! let mut builder = TypedBuilder::::default(); //! let mut builder_root = builder.init_root(); //! builder_root.set_x(10); //! builder_root.set_y(20); @@ -438,7 +438,7 @@ where pub fn get_root_as_reader<'a, T: FromPointerReader<'a>>(&'a self) -> Result { if self.arena.is_empty() { - any_pointer::Reader::new(layout::PointerReader::new_default()).get_as() + any_pointer::Reader::new(layout::PointerReader::default()).get_as() } else { let (segment_start, _segment_len) = self.arena.get_segment(0)?; let pointer_reader = layout::PointerReader::get_root( @@ -526,12 +526,22 @@ where message: Builder, } +impl Default for TypedBuilder +where + T: Owned, +{ + fn default() -> Self { + Self::new(Builder::default()) + } +} + impl TypedBuilder where T: Owned, { + #[deprecated(since = "0.15.2", note = "use 'default()' instead")] pub fn new_default() -> Self { - Self::new(Builder::new_default()) + Self::new(Builder::default()) } } @@ -708,9 +718,18 @@ fn test_allocate_max() { allocator.deallocate_segment(a3, s3, 0); } +impl Default for Builder { + /// Constructs a new `message::Builder` whose first segment has length + /// `SUGGESTED_FIRST_SEGMENT_WORDS`. + fn default() -> Self { + Self::new(HeapAllocator::new()) + } +} + impl Builder { /// Constructs a new `message::Builder` whose first segment has length /// `SUGGESTED_FIRST_SEGMENT_WORDS`. + #[deprecated(since = "0.15.2", note = "use 'default()' instead")] pub fn new_default() -> Self { Self::new(HeapAllocator::new()) } diff --git a/capnp/src/private/layout.rs b/capnp/src/private/layout.rs index 559e2b82c..e25e68304 100644 --- a/capnp/src/private/layout.rs +++ b/capnp/src/private/layout.rs @@ -1335,7 +1335,7 @@ mod wire_helpers { if (*orig_ref).is_null() { if default_value.is_null() || (*(default_value as *const WirePointer)).is_null() { - return Ok(ListBuilder::new_default()); + return Ok(ListBuilder::default()); } let (new_orig_ref_target, new_orig_ref, new_orig_segment_id) = copy_message( arena, @@ -1468,7 +1468,7 @@ mod wire_helpers { if (*orig_ref).is_null() { if default_value.is_null() || (*(default_value as *const WirePointer)).is_null() { - return Ok(ListBuilder::new_default()); + return Ok(ListBuilder::default()); } let (new_orig_ref_target, new_orig_ref, new_orig_segment_id) = copy_message( arena, @@ -2356,9 +2356,9 @@ mod wire_helpers { ) -> Result> { if (*reff).is_null() { match default { - None => return Ok(StructReader::new_default()), + None => return Ok(StructReader::default()), Some(d) if (*(d.as_ptr() as *const WirePointer)).is_null() => { - return Ok(StructReader::new_default()) + return Ok(StructReader::default()) } Some(d) => { reff = d.as_ptr() as *const _; @@ -2446,7 +2446,7 @@ mod wire_helpers { ) -> Result> { if (*reff).is_null() { if default_value.is_null() || (*(default_value as *const WirePointer)).is_null() { - return Ok(ListReader::new_default()); + return Ok(ListReader::default()); } reff = default_value as *const _; arena = &super::NULL_ARENA; @@ -2827,9 +2827,9 @@ pub struct PointerReader<'a> { nesting_limit: i32, } -impl<'a> PointerReader<'a> { - pub fn new_default<'b>() -> PointerReader<'b> { - PointerReader { +impl<'a> Default for PointerReader<'a> { + fn default() -> Self { + Self { arena: &NULL_ARENA, segment_id: 0, cap_table: CapTableReader::Plain(ptr::null()), @@ -2837,6 +2837,13 @@ impl<'a> PointerReader<'a> { nesting_limit: 0x7fffffff, } } +} + +impl<'a> PointerReader<'a> { + #[deprecated(since = "0.15.2", note = "use 'default()' instead")] + pub fn new_default() -> Self { + Self::default() + } pub fn get_root( arena: &'a dyn ReaderArena, @@ -3348,9 +3355,9 @@ pub struct StructReader<'a> { nesting_limit: i32, } -impl<'a> StructReader<'a> { - pub fn new_default<'b>() -> StructReader<'b> { - StructReader { +impl<'a> Default for StructReader<'a> { + fn default() -> Self { + Self { arena: &NULL_ARENA, segment_id: 0, cap_table: CapTableReader::Plain(ptr::null()), @@ -3361,6 +3368,13 @@ impl<'a> StructReader<'a> { nesting_limit: 0x7fffffff, } } +} + +impl<'a> StructReader<'a> { + #[deprecated(since = "0.15.2", note = "use 'default()' instead")] + pub fn new_default() -> Self { + Self::default() + } pub fn imbue(&mut self, cap_table: CapTableReader) { self.cap_table = cap_table @@ -3452,7 +3466,7 @@ impl<'a> StructReader<'a> { nesting_limit: self.nesting_limit, } } else { - PointerReader::new_default() + PointerReader::default() } } @@ -3729,9 +3743,9 @@ pub struct ListReader<'a> { element_size: ElementSize, } -impl<'a> ListReader<'a> { - pub fn new_default<'b>() -> ListReader<'b> { - ListReader { +impl<'a> Default for ListReader<'a> { + fn default() -> Self { + Self { arena: &NULL_ARENA, segment_id: 0, cap_table: CapTableReader::Plain(ptr::null()), @@ -3744,6 +3758,13 @@ impl<'a> ListReader<'a> { nesting_limit: 0x7fffffff, } } +} + +impl<'a> ListReader<'a> { + #[deprecated(since = "0.15.2", note = "use 'default()' instead")] + pub fn new_default() -> Self { + Self::default() + } pub fn imbue(&mut self, cap_table: CapTableReader) { self.cap_table = cap_table @@ -3938,9 +3959,8 @@ pub struct ListBuilder<'a> { element_size: ElementSize, } -impl<'a> ListBuilder<'a> { - #[inline] - pub fn new_default<'b>() -> ListBuilder<'b> { +impl<'a> Default for ListBuilder<'a> { + fn default() -> Self { ListBuilder { arena: &NULL_ARENA, segment_id: 0, @@ -3953,6 +3973,14 @@ impl<'a> ListBuilder<'a> { struct_pointer_count: 0, } } +} + +impl<'a> ListBuilder<'a> { + #[inline] + #[deprecated(since = "0.15.2", note = "use 'default()' instead")] + pub fn new_default() -> Self { + Self::default() + } pub fn into_reader(self) -> ListReader<'a> { ListReader { diff --git a/capnp/src/serialize.rs b/capnp/src/serialize.rs index 8f719ed8b..461fb8ae8 100644 --- a/capnp/src/serialize.rs +++ b/capnp/src/serialize.rs @@ -935,7 +935,7 @@ pub mod test { #[test] fn compute_serialized_size() { const LIST_LENGTH_IN_WORDS: u32 = 5; - let mut m = message::Builder::new_default(); + let mut m = message::Builder::default(); { let root: crate::any_pointer::Builder = m.init_root(); let _list_builder: crate::primitive_list::Builder = diff --git a/capnpc/test/test.rs b/capnpc/test/test.rs index b3d3c05dc..388fc3a4d 100644 --- a/capnpc/test/test.rs +++ b/capnpc/test/test.rs @@ -294,7 +294,7 @@ mod tests { fn test_complex_list() { use crate::test_capnp::{test_complex_list, AnEnum}; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut test_complex_list = message.init_root::>(); @@ -458,8 +458,8 @@ mod tests { fn test_list_list_set_elem() { use crate::test_capnp::test_complex_list; - let mut message1 = message::Builder::new_default(); - let mut message2 = message::Builder::new_default(); + let mut message1 = message::Builder::default(); + let mut message2 = message::Builder::default(); let mut test_complex_list1 = message1.init_root::>(); let mut test_complex_list2 = message2.init_root::>(); @@ -492,7 +492,7 @@ mod tests { use crate::test_capnp::test_defaults; { - let message = message::Builder::new_default(); + let message = message::Builder::default(); let test_defaults = message .get_root_as_reader::>() .expect("get_root_as_reader()"); @@ -500,13 +500,13 @@ mod tests { } { - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let test_defaults = message.init_root::>(); CheckTestMessage::check_test_message(test_defaults); } { - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut test_defaults = message .get_root::>() .expect("get_root()"); @@ -564,7 +564,7 @@ mod tests { fn test_any_pointer() { use crate::test_capnp::{test_any_pointer, test_big_struct, test_empty_struct}; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut test_any_pointer = message.init_root::>(); test_any_pointer @@ -603,7 +603,7 @@ mod tests { } { - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut test_big_struct = message.init_root::>(); test_big_struct.set_int32_field(-12345); test_any_pointer @@ -613,7 +613,7 @@ mod tests { } fn _test_lifetimes(body: test_big_struct::Reader<'_>) { - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); message.set_root(body).unwrap(); } } @@ -622,7 +622,7 @@ mod tests { fn test_writable_struct_pointer() { use crate::test_capnp::test_big_struct; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut big_struct = message.init_root::>(); let neg_seven: u64 = (-7i64) as u64; @@ -664,7 +664,7 @@ mod tests { .set_uint32_field(4294967265); // Alas, we need to make a copy to appease the reborrow checker. - let mut other_message = message::Builder::new_default(); + let mut other_message = message::Builder::default(); other_message .set_root( big_struct @@ -719,7 +719,7 @@ mod tests { fn test_generic_one_parameter() { use crate::test_capnp::brand_once; - let mut message_for_brand = message::Builder::new_default(); + let mut message_for_brand = message::Builder::default(); let mut branded = message_for_brand.init_root::>(); { let branded_field = branded.reborrow().init_branded_field(); @@ -744,7 +744,7 @@ mod tests { fn test_generic_two_parameter() { use crate::test_capnp::brand_twice; - let mut message_for_brand = message::Builder::new_default(); + let mut message_for_brand = message::Builder::default(); let mut branded = message_for_brand.init_root::>(); { let mut baz = branded.reborrow().init_baz_field(); @@ -785,7 +785,7 @@ mod tests { fn test_generics() { use crate::test_capnp::{test_all_types, test_generics}; use capnp::text; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut root: test_generics::Builder<'_, test_all_types::Owned, text::Owned> = message.init_root(); init_test_message(root.reborrow().get_foo().unwrap()); @@ -817,7 +817,7 @@ mod tests { fn test_generic_union() { use crate::test_capnp::{test_all_types, test_generics_union}; use capnp::primitive_list; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut root: test_generics_union::Builder< '_, @@ -865,7 +865,7 @@ mod tests { use crate::test_capnp::{test_all_types, test_generics_groups}; use capnp::primitive_list; { - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut root: test_generics_groups::Builder< '_, @@ -891,7 +891,7 @@ mod tests { } { - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut root: test_generics_groups::inner::Builder< '_, @@ -929,7 +929,7 @@ mod tests { fn test_union() { use crate::test_capnp::test_union; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut union_struct = message.init_root::>(); union_struct.reborrow().get_union0().set_u0f0s0(()); @@ -958,7 +958,7 @@ mod tests { use crate::test_capnp::{test_union, test_union_defaults}; { - let message = message::Builder::new_default(); + let message = message::Builder::default(); let reader = message .get_root_as_reader::>() .expect("get_root_as_reader()"); @@ -1065,8 +1065,8 @@ mod tests { fn test_set_root() { use crate::test_capnp::test_big_struct; - let mut message1 = message::Builder::new_default(); - let mut message2 = message::Builder::new_default(); + let mut message1 = message::Builder::default(); + let mut message2 = message::Builder::default(); let mut struct1 = message1.init_root::>(); struct1.set_uint8_field(3); message2.set_root(struct1.into_reader()).unwrap(); @@ -1079,7 +1079,7 @@ mod tests { fn upgrade_struct() { use crate::test_capnp::{test_new_version, test_old_version}; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut old_version = message.init_root::>(); old_version.set_old1(123); @@ -1109,7 +1109,7 @@ mod tests { fn upgraded_struct_read_as_old() { use crate::test_capnp::{test_new_version, test_old_version}; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut new_version = message.init_root::>(); new_version.set_old1(123); @@ -1133,7 +1133,7 @@ mod tests { fn upgrade_union() { use crate::test_capnp::{test_new_union_version, test_old_union_version}; // This tests for a specific case that was broken originally. - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut old_version = message.init_root::>(); old_version.set_b(123); @@ -1155,7 +1155,7 @@ mod tests { use crate::test_capnp::{test_any_pointer, test_lists}; { - let mut builder = message::Builder::new_default(); + let mut builder = message::Builder::default(); let mut root = builder.init_root::>(); { let mut list = root @@ -1179,7 +1179,7 @@ mod tests { } { - let mut builder = message::Builder::new_default(); + let mut builder = message::Builder::default(); let mut root = builder.init_root::>(); { let mut list = root @@ -1281,7 +1281,7 @@ mod tests { let segment0 = &segment0_outer[..7]; // everything except the trailing 3 words { - let mut message_builder = capnp::message::Builder::new_default(); + let mut message_builder = capnp::message::Builder::default(); let segment_array = &[capnp::Word::words_to_bytes(segment0)]; let message_reader = message::Reader::new( @@ -1306,7 +1306,7 @@ mod tests { fn all_types() { use crate::test_capnp::test_all_types; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); init_test_message(message.init_root()); CheckTestMessage::check_test_message( message.get_root::>().unwrap(), @@ -1344,11 +1344,11 @@ mod tests { use crate::test_capnp::test_all_types; { - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); init_test_message(message.init_root::>()); - let mut message2 = message::Builder::new_default(); + let mut message2 = message::Builder::default(); let mut all_types2 = message2.init_root::>(); all_types2 @@ -1517,7 +1517,7 @@ mod tests { .get_root::>() .unwrap(); assert!(reader.total_size().is_err()); - let mut builder = ::capnp::message::Builder::new_default(); + let mut builder = ::capnp::message::Builder::default(); assert!(builder.set_root(reader).is_err()); } @@ -1525,7 +1525,7 @@ mod tests { fn text_builder_int_underflow() { use crate::test_capnp::test_any_pointer; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut root = message.init_root::>(); let _: ::capnp::data::Builder<'_> = root.reborrow().get_any_pointer_field().initn_as(0); @@ -1570,7 +1570,7 @@ mod tests { assert!(result.is_err()); } - let mut message_builder = message::Builder::new_default(); + let mut message_builder = message::Builder::default(); let builder_root = message_builder.init_root::>(); match builder_root.get_any_pointer_field().set_as(root) { @@ -1589,7 +1589,7 @@ mod tests { let length: u32 = 1 << 27; let step_exponent = 18; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let root: test_all_types::Builder<'_> = message.init_root(); let mut list = root.init_u_int64_list(length); @@ -1603,7 +1603,7 @@ mod tests { } } - let mut message2 = message::Builder::new_default(); + let mut message2 = message::Builder::default(); { let root: test_all_types::Reader<'_> = message.get_root_as_reader().unwrap(); let mut root2: test_all_types::Builder<'_> = message2.init_root(); @@ -1631,7 +1631,7 @@ mod tests { let length: u32 = 1 << 27; let step_exponent = 18; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let root: test_lists::Builder<'_> = message.init_root(); let mut list = root.init_list64(length); @@ -1660,7 +1660,7 @@ mod tests { let length: u32 = 1 << 27; let step_exponent = 18; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let root: test_lists::Builder<'_> = message.init_root(); let mut list = root.init_int32_list_list(length); @@ -1690,7 +1690,7 @@ mod tests { fn traversal_limit_exceeded() { use crate::test_capnp::test_all_types; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); init_test_message(message.init_root()); let segments = message.get_segments_for_output(); @@ -1708,7 +1708,7 @@ mod tests { fn void_list_amplification() { use crate::test_capnp::{test_all_types, test_any_pointer}; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let root = message.init_root::>(); let _: ::capnp::primitive_list::Builder<'_, ()> = @@ -1731,7 +1731,7 @@ mod tests { fn empty_struct_list_amplification() { use crate::test_capnp::{test_all_types, test_any_pointer, test_empty_struct}; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let root = message.init_root::>(); let _: ::capnp::struct_list::Builder<'_, test_empty_struct::Owned> = @@ -1778,14 +1778,14 @@ mod tests { .unwrap(); reader.total_size().unwrap(); - let mut builder = ::capnp::message::Builder::new_default(); + let mut builder = ::capnp::message::Builder::default(); assert!(builder.set_root(reader).is_err()); // read limit exceeded } #[test] fn null_struct_fields() { use crate::test_capnp::test_all_types; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut test = message.init_root::>(); test.set_text_field("Hello"); @@ -1817,17 +1817,17 @@ mod tests { #[test] fn set_with_caveats() { use crate::test_capnp::test_all_types; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let root: test_all_types::Builder<'_> = message.init_root(); let list = root.init_struct_list(2); { - let mut message1 = message::Builder::new_default(); + let mut message1 = message::Builder::default(); let mut root1: test_all_types::Builder<'_> = message1.init_root(); root1.set_int8_field(11); list.set_with_caveats(0, root1.into_reader()).unwrap(); } { - let mut message2 = message::Builder::new_default(); + let mut message2 = message::Builder::default(); let mut root2: test_all_types::Builder<'_> = message2.init_root(); init_test_message(root2.reborrow()); list.set_with_caveats(1, root2.into_reader()).unwrap(); @@ -1842,7 +1842,7 @@ mod tests { fn get_raw_struct_data() { use crate::test_capnp::test_all_types; use capnp::traits::HasStructSize; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut root: test_all_types::Builder<'_> = message.init_root(); root.set_int8_field(3); root.set_int16_field(0x0abb); @@ -1860,7 +1860,7 @@ mod tests { #[test] fn get_raw_list_data() { use crate::test_capnp::test_all_types; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut root: test_all_types::Builder<'_> = message.init_root(); { let mut uint16_list = root.reborrow().init_u_int16_list(5); @@ -1889,7 +1889,7 @@ mod tests { #[test] fn get_struct_pointer_section() { use crate::test_capnp::test_all_types; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); let mut root: test_all_types::Builder<'_> = message.init_root(); init_test_message(root.reborrow().init_struct_field()); let pointers = ::capnp::raw::get_struct_pointer_section(root.into_reader()); @@ -1900,7 +1900,7 @@ mod tests { #[test] fn struct_list_iterator() { use crate::test_capnp::test_all_types; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let root: test_all_types::Builder<'_> = message.init_root(); let mut struct_list = root.init_struct_list(6); @@ -1954,7 +1954,7 @@ mod tests { #[test] fn name_annotation() { use crate::test_capnp::renamed_struct; - let mut message = message::Builder::new_default(); + let mut message = message::Builder::default(); { let mut root: renamed_struct::Builder<'_> = message.init_root(); root.set_good_field_name(true); @@ -1984,7 +1984,7 @@ mod tests { fn test_typed_builder_reader() { use crate::test_capnp::test_all_types; - let mut typed_builder = TypedBuilder::::new_default(); + let mut typed_builder = TypedBuilder::::default(); init_test_message(typed_builder.init_root()); CheckTestMessage::check_test_message(typed_builder.get_root().unwrap()); @@ -2003,7 +2003,7 @@ mod tests { fn test_slice_segments() { use crate::test_capnp::test_all_types; - let mut typed_builder = TypedBuilder::::new_default(); + let mut typed_builder = TypedBuilder::::default(); init_test_message(typed_builder.init_root()); CheckTestMessage::check_test_message(typed_builder.get_root().unwrap()); @@ -2025,7 +2025,7 @@ mod tests { fn test_no_alloc_slice_segments() { use crate::test_capnp::test_all_types; - let mut typed_builder = TypedBuilder::::new_default(); + let mut typed_builder = TypedBuilder::::default(); init_test_message(typed_builder.init_root()); CheckTestMessage::check_test_message(typed_builder.get_root().unwrap()); diff --git a/example/addressbook/addressbook.rs b/example/addressbook/addressbook.rs index 9fa6159b7..729d09f62 100644 --- a/example/addressbook/addressbook.rs +++ b/example/addressbook/addressbook.rs @@ -28,7 +28,7 @@ pub mod addressbook { use capnp::serialize_packed; pub fn write_address_book() -> ::capnp::Result<()> { - let mut message = ::capnp::message::Builder::new_default(); + let mut message = ::capnp::message::Builder::default(); { let address_book = message.init_root::(); diff --git a/example/addressbook_send/addressbook_send.rs b/example/addressbook_send/addressbook_send.rs index 65fdc718a..6abf40d6f 100644 --- a/example/addressbook_send/addressbook_send.rs +++ b/example/addressbook_send/addressbook_send.rs @@ -32,7 +32,7 @@ pub mod addressbook { use capnp::message::{Builder, HeapAllocator, TypedBuilder, TypedReader}; pub fn build_address_book() -> TypedReader, address_book::Owned> { - let mut message = TypedBuilder::::new_default(); + let mut message = TypedBuilder::::default(); { let address_book = message.init_root(); diff --git a/example/wasm-hello-world/src/main.rs b/example/wasm-hello-world/src/main.rs index a83f99a0c..13893a7b4 100644 --- a/example/wasm-hello-world/src/main.rs +++ b/example/wasm-hello-world/src/main.rs @@ -17,7 +17,7 @@ fn main() -> Result<(), Box> { let memory = instance.exports.get_memory("memory")?; let mut expected_total: i32 = 0; - let mut message = capnp::message::Builder::new_default(); + let mut message = capnp::message::Builder::default(); { let root: wasm_hello_world_capnp::foo::Builder = message.init_root(); let mut numbers = root.init_numbers(10);