lv-std 0.0.4

some utils for c and unsafe rust, this is for personal use for now so you can use it but don't expect any regular updates or maintaining
Documentation
use std::cell::UnsafeCell;
use std::marker::PhantomData;
use std::mem::{transmute, ManuallyDrop};
use std::ops::{Deref, DerefMut};
use std::ptr::NonNull;
use crate::unsafe_std::ptrs::raw_ptr::RawPtr;

#[repr(transparent)]
#[derive(Copy, Clone)]
pub struct UnsafeShared<T> {
    value: T
}

impl<T> UnsafeShared<T> {
    #[inline(always)]
    pub unsafe fn new(value: T) -> Self {
        Self {
            value
        }
    }

    #[inline(always)]
    pub unsafe fn take_ref(&mut self) -> UnsafeSharedRef<T> {
        UnsafeSharedRef{ptr: NonNull::<UnsafeCell<T>>::from_mut( transmute(UnsafeCell::new(&mut self.value)))  }
    }
}

impl<T> Deref for UnsafeShared<T> {
    type Target = T;

    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.value
    }
}

impl<T> DerefMut for UnsafeShared<T> {
    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.value
    }
}


#[derive(Copy, Clone)]
pub struct UnsafeSharedRef<T> {
    ptr: NonNull<UnsafeCell<T>>,
}

impl<T> Deref for UnsafeSharedRef<T> {
    type Target = T;

    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        unsafe { transmute(self.ptr.as_ref().get())}
    }
}

impl<T> DerefMut for UnsafeSharedRef<T> {

    #[inline(always)]
    fn deref_mut(&mut self) -> &mut Self::Target {
        unsafe { transmute(self.ptr.as_ref().get())}
    }
}