Skip to content

Commit c48c9d4

Browse files
committed
expand as_slice() doc comment
1 parent 8a10b4a commit c48c9d4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

capnp/src/primitive_list.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,13 @@ impl<'a, T: PrimitiveElement> Reader<'a, T> {
114114

115115
const _CHECK_SLICE: () = check_slice_supported::<T>();
116116

117-
/// Returns something if the slice is as expected in memory.
117+
/// Attempts to return a view of the list as a native Rust slice.
118+
/// Returns `None` if the elements of the list are non-contiguous,
119+
/// which can happen if the schema has evolved.
118120
///
119-
/// If the target is not little-endian or the `unaligned` feature is enabled, this function
120-
/// will only be available for types that are 1 byte or smaller.
121+
/// This method raises a compile-time error if `T` is larger than one
122+
/// byte and either the `unaligned` feature is enabled or the target
123+
/// is big-endian.
121124
pub fn as_slice(&self) -> Option<&[T]> {
122125
let () = Self::_CHECK_SLICE;
123126
if self.reader.get_element_size() == T::element_size() {
@@ -196,6 +199,13 @@ where
196199

197200
const _CHECK_SLICE: () = check_slice_supported::<T>();
198201

202+
/// Attempts to return a view of the list as a native Rust slice.
203+
/// Returns `None` if the elements of the list are non-contiguous,
204+
/// which can happen if the schema has evolved.
205+
///
206+
/// This method raises a compile-time error if `T` is larger than one
207+
/// byte and either the `unaligned` feature is enabled or the target
208+
/// is big-endian.
199209
pub fn as_slice(&mut self) -> Option<&mut [T]> {
200210
let () = Self::_CHECK_SLICE;
201211
if self.builder.get_element_size() == T::element_size() {

0 commit comments

Comments
 (0)