Skip to content

Commit

Permalink
expand as_slice() doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed May 13, 2024
1 parent 8a10b4a commit c48c9d4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions capnp/src/primitive_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ impl<'a, T: PrimitiveElement> Reader<'a, T> {

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

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

Check warning on line 125 in capnp/src/primitive_list.rs

View workflow job for this annotation

GitHub Actions / lint

this let-binding has unit value

warning: this let-binding has unit value --> capnp/src/primitive_list.rs:125:9 | 125 | let () = Self::_CHECK_SLICE; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `Self::_CHECK_SLICE;` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value = note: `#[warn(clippy::let_unit_value)]` on by default
if self.reader.get_element_size() == T::element_size() {
Expand Down Expand Up @@ -196,6 +199,13 @@ where

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

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

Check warning on line 210 in capnp/src/primitive_list.rs

View workflow job for this annotation

GitHub Actions / lint

this let-binding has unit value

warning: this let-binding has unit value --> capnp/src/primitive_list.rs:210:9 | 210 | let () = Self::_CHECK_SLICE; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `Self::_CHECK_SLICE;` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
if self.builder.get_element_size() == T::element_size() {
Expand Down

0 comments on commit c48c9d4

Please sign in to comment.