Skip to content

Commit 1ce11c2

Browse files
committed
add message::Builder::initn_root()
1 parent 359464d commit 1ce11c2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

capnp/src/message.rs

+10
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ where
443443
root.init_as()
444444
}
445445

446+
/// Initializes the root as a value of the given list type, with the given length.
447+
pub fn initn_root<'a, T: FromPointerBuilder<'a>>(&'a mut self, length: u32) -> T {
448+
let root = self.get_root_internal();
449+
root.initn_as(length)
450+
}
451+
446452
/// Gets the root, interpreting it as the given type.
447453
pub fn get_root<'a, T: FromPointerBuilder<'a>>(&'a mut self) -> Result<T> {
448454
let root = self.get_root_internal();
@@ -566,6 +572,10 @@ where
566572
self.message.init_root()
567573
}
568574

575+
pub fn initn_root(&mut self, length: u32) -> T::Builder<'_> {
576+
self.message.initn_root(length)
577+
}
578+
569579
pub fn get_root(&mut self) -> Result<T::Builder<'_>> {
570580
self.message.get_root()
571581
}

0 commit comments

Comments
 (0)