From 0cbd0b9b701c4d067b8dd0fdccc0ebe5c6b6e7e1 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Fri, 12 Aug 2022 15:29:07 -0300 Subject: Provide ConstLtPtr to CStr conversion --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 90cef27..7ce25cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: 0BSD #![cfg_attr(not(feature="std"),no_std)] +#![deny(unsafe_op_in_unsafe_fn)] //! This crate provides "checked" raw pointers. //! @@ -107,6 +108,13 @@ pub trait AsLtPtr { fn as_lt_ptr<'a>(&'a self) -> ConstLtPtr<'a, Self::Target>; } +/// Trait for conversion from a [`ConstLtPtr`] of the given `Source` type. +pub trait FromLtPtr { + /// Returns a value as if by `from_ptr` on a type that implements this, but + /// with a bound lifetime. + unsafe fn from_lt_ptr<'a>(ptr: ConstLtPtr<'a, Source>) -> &'a Self; +} + /// Trait for conversion into a [`MutLtPtr`]. pub trait AsMutLtPtr: AsLtPtr { /// Returns a pointer as if by `as_ptr` on a type that implements this, but -- cgit 1.4.1