pub struct CStrPtr(/* private fields */);Expand description
Simple wrapper to treat a raw pointer to an array of C-style strings as a AsCStrArray
This is useful for passing raw pointers obtained from other sources (e.g.,
FFI) to functions that expect an AsCStrArray. However, it is the caller’s
responsibility to ensure that the pointer validly points to a
null-terminated array of pointers to valid C-style strings, and that the
array and strings remain valid for the required lifetime. This wrapper does
not take ownership of the array or strings.
You should prefer BorrowedCStrs or OwnedCStrs over this type when
possible, as they provide ownership and lifetime guarantees for the strings.
Implementations§
Source§impl CStrPtr
impl CStrPtr
Sourcepub unsafe fn new(ptr: *const *const c_char) -> Self
pub unsafe fn new(ptr: *const *const c_char) -> Self
Create a new CStrPtr from a raw pointer to an array of C-style strings.
The given pointer is directly returned by the as_ptr
method.
§Safety
The caller must ensure that ptr points to a valid null-terminated
array of pointers to valid C-style strings. The array and strings must
remain valid and unmodified until the CStrPtr is dropped.
Trait Implementations§
Source§impl AsCStrArray for CStrPtr
impl AsCStrArray for CStrPtr
impl Copy for CStrPtr
impl Eq for CStrPtr
Source§impl Ord for CStrPtr
impl Ord for CStrPtr
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for CStrPtr
impl PartialOrd for CStrPtr
impl StructuralPartialEq for CStrPtr
Auto Trait Implementations§
impl !Send for CStrPtr
impl !Sync for CStrPtr
impl Freeze for CStrPtr
impl RefUnwindSafe for CStrPtr
impl Unpin for CStrPtr
impl UnsafeUnpin for CStrPtr
impl UnwindSafe for CStrPtr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoCStrArray for Twhere
T: AsCStrArray,
impl<T> IntoCStrArray for Twhere
T: AsCStrArray,
Source§type CStrArray = T
type CStrArray = T
self can be converted into, which must implement AsCStrArray.Source§fn into_c_str_array(self) -> <T as IntoCStrArray>::CStrArray
fn into_c_str_array(self) -> <T as IntoCStrArray>::CStrArray
self into a type that implements AsCStrArray.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more