Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/wpf-gpu-raster/src/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  nullable_ref.rs

  Sprache: Rust
 

use std::{marker::PhantomData, ops::Deref};

pub struct Ref<'a, T> {
    ptr: *const T,
    _phantom: PhantomData<&'a T>
}

impl<'a, T> Copy for Ref<'a, T> { }

impl<'a, T> Clone for Ref<'a, T> {
    fn clone(&self) -> Self {
        *self
    }
}

impl<'a, T> Ref<'a, T> {
    pub fn new(p: &'a T) -> Self {
        Ref { ptr: p as *const T, _phantom: PhantomData}
    }
    pub unsafe fn null() -> Self {
        Ref { ptr: std::ptr::null(), _phantom: PhantomData}
    }
    pub fn is_null(&self) -> bool {
        self.ptr.is_null()
    }
    pub fn get_ref(self) -> &'a T {
        unsafe { &*self.ptr }
    }
}

impl<'a, T> PartialEq for Ref<'a, T> {
    fn eq(&self, other: &Self) -> bool {
        self.ptr == other.ptr && self._phantom == other._phantom
    }
}

impl<'a, T> PartialOrd for Ref<'a, T> {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        match self.ptr.partial_cmp(&other.ptr) {
            Some(core::cmp::Ordering::Equal) => {}
            ord => return ord,
        }
        self._phantom.partial_cmp(&other._phantom)
    }
}

impl<'a, T> Deref for Ref<'a, T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        unsafe { &*self.ptr }
    }
}

Messung V0.5 in Prozent
C=100 H=89 G=94

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-17) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.