Trait JavaStrSliceIndex

Source
pub unsafe trait JavaStrSliceIndex: Sealed + Sized {
    // Required methods
    fn check_bounds(&self, slice: &JavaStr) -> bool;
    fn check_bounds_fail(self, slice: &JavaStr) -> !;
    unsafe fn get_unchecked(self, slice: *const JavaStr) -> *const JavaStr;
    unsafe fn get_unchecked_mut(self, slice: *mut JavaStr) -> *mut JavaStr;

    // Provided methods
    fn get(self, slice: &JavaStr) -> Option<&JavaStr> { ... }
    fn get_mut(self, slice: &mut JavaStr) -> Option<&mut JavaStr> { ... }
    fn index(self, slice: &JavaStr) -> &JavaStr { ... }
    fn index_mut(self, slice: &mut JavaStr) -> &mut JavaStr { ... }
}
Expand description

§Safety

Implementations’ check_bounds method must properly check the bounds of the slice, such that calling get_unchecked is not UB.

Required Methods§

Source

fn check_bounds(&self, slice: &JavaStr) -> bool

Source

fn check_bounds_fail(self, slice: &JavaStr) -> !

Source

unsafe fn get_unchecked(self, slice: *const JavaStr) -> *const JavaStr

§Safety
  • The input slice must be a valid pointer
  • This index must not be out of bounds of the input slice
  • The indices of this slice must point to char boundaries in the input slice
Source

unsafe fn get_unchecked_mut(self, slice: *mut JavaStr) -> *mut JavaStr

§Safety
  • The input slice must be a valid pointer
  • This index must not be out of bounds of the input slice
  • The indices of this slice must point to char boundaries in the input slice

Provided Methods§

Source

fn get(self, slice: &JavaStr) -> Option<&JavaStr>

Source

fn get_mut(self, slice: &mut JavaStr) -> Option<&mut JavaStr>

Source

fn index(self, slice: &JavaStr) -> &JavaStr

Source

fn index_mut(self, slice: &mut JavaStr) -> &mut JavaStr

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl JavaStrSliceIndex for Range<usize>

Source§

impl JavaStrSliceIndex for RangeFrom<usize>

Source§

impl JavaStrSliceIndex for RangeFull

Source§

impl JavaStrSliceIndex for RangeInclusive<usize>

Source§

impl JavaStrSliceIndex for RangeTo<usize>

Source§

impl JavaStrSliceIndex for RangeToInclusive<usize>

Implementors§