Skip to content

Commit 5a28c0f

Browse files
committed
add is_empty() methods
1 parent 547a848 commit 5a28c0f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

capnp/src/text.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ impl<'a> crate::traits::FromPointerReader<'a> for Reader<'a> {
102102
}
103103

104104
impl<'a> Reader<'a> {
105+
/// The string's length, in bytes.
105106
pub fn len(&self) -> usize {
106107
self.as_bytes().len()
107108
}
108109

110+
pub fn is_empty(&self) -> bool {
111+
self.len() == 0
112+
}
113+
109114
pub fn as_bytes(self) -> &'a [u8] {
110115
let Self(d) = self;
111116
d
@@ -159,10 +164,15 @@ impl<'a> Builder<'a> {
159164
Builder { bytes, pos }
160165
}
161166

167+
/// The string's length, in bytes.
162168
pub fn len(&self) -> usize {
163169
self.bytes.len()
164170
}
165171

172+
pub fn is_empty(&self) -> bool {
173+
self.len() == 0
174+
}
175+
166176
pub fn as_bytes(self) -> &'a [u8] {
167177
&self.bytes[..]
168178
}

0 commit comments

Comments
 (0)