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


/* 
To be used later on, I prefer focusing on the RawPtr
 */

/*
use std::marker::PhantomData;
use std::mem::{transmute, transmute_copy};
use crate::unsafe_std::ptrs::raw_ptr::RawPtr;

#[repr(transparent)]
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct RawConstPtr<T> {
    ptr: *const T,
    _marker: PhantomData<T>,
}

impl<T> RawConstPtr<T> {

    const NULL: RawConstPtr<T> = RawConstPtr::null();


    #[inline(always)]
    pub const fn new(value: &T) -> RawConstPtr<T> {
        Self {
            ptr: value as *const T,
            _marker: PhantomData,
        }
    }

    #[inline(always)]
    pub const fn null() -> RawConstPtr<T> {
        Self {
            ptr: std::ptr::null_mut(),
            _marker: PhantomData,
        }
    }

    #[inline(always)]
    pub const unsafe fn index(&self, index: isize) -> &T {
        &*self.ptr.offset(index)
    }

    #[inline(always)]
    pub const fn is_null(&self) -> bool {
        self.ptr.is_null()
    }

    #[inline(always)]
    pub const unsafe fn as_ref(&self) -> Option<&T> {
        self.ptr.as_ref()
    }

    #[inline(always)]
    pub const unsafe fn as_const_raw(&self) -> Option<*const T> {
        if self.ptr.is_null() {
            None
        } else {
            Some(self.ptr as  *const T)
        }
    }

    #[inline(always)]
    pub const unsafe fn const_cast_mut(self) -> RawPtr<T> {
        transmute(self)
    }

    #[inline(always)]
    pub const unsafe fn cast<U>(self) -> RawConstPtr<U> {
        transmute(self)
    }

    #[inline(always)]
    pub const unsafe fn cast_ref<U>(&self) -> &U {
        transmute(self.ptr as *const U)
    }

    #[inline(always)]
    pub const unsafe fn cast_const_raw<U>(&mut self) -> *const U {
        transmute(self.ptr)
    }
}*/