Change slice length check to use stable method

This commit is contained in:
Til Blechschmidt 2022-02-23 23:30:50 +01:00
parent 66fdec7abe
commit 6dc58645d2
No known key found for this signature in database
GPG Key ID: 2F4E54D35C8390CB
2 changed files with 3 additions and 2 deletions

View File

@ -1,7 +1,7 @@
#![no_std] #![no_std]
#![cfg_attr( #![cfg_attr(
feature = "nightly", feature = "nightly",
feature(generic_associated_types, type_alias_impl_trait, slice_ptr_len) feature(generic_associated_types, type_alias_impl_trait)
)] )]
#[cfg(not(any( #[cfg(not(any(

View File

@ -22,7 +22,8 @@ pub(crate) fn slice_in_ram<T>(slice: *const [T]) -> bool {
/// Return an error if slice is not in RAM. Skips check if slice is zero-length. /// Return an error if slice is not in RAM. Skips check if slice is zero-length.
#[cfg(not(feature = "nrf51"))] #[cfg(not(feature = "nrf51"))]
pub(crate) fn slice_in_ram_or<T, E>(slice: *const [T], err: E) -> Result<(), E> { pub(crate) fn slice_in_ram_or<T, E>(slice: *const [T], err: E) -> Result<(), E> {
if slice.len() > 0 && slice_in_ram(slice) { let (_, len) = slice_ptr_parts(slice);
if len > 0 && slice_in_ram(slice) {
Ok(()) Ok(())
} else { } else {
Err(err) Err(err)