From: Ian Jackson Date: Fri, 15 Nov 2024 16:03:16 +0000 (+0000) Subject: provide from_raw X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=dd339573e0003e379e97ca64836442b009fcacb4;p=manually-boxed provide from_raw --- diff --git a/src/lib.rs b/src/lib.rs index f2a35f7..4b6ccee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -401,6 +401,16 @@ impl Ptr { }; t } + + /// Make a new `Ptr` out of a raw pointer + /// + /// # SAFETY + /// + /// It is up to you to ensure that the pointer is valid for `T`, + /// dereferencable, and has appropriate lifespan. + pub unsafe fn from_raw(t: NonNull) -> Self { + Ptr { ptr: t } + } } impl NoAliasSingleton {