Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  as.rs

  Sprache: Rust
 

//! Type glue for [autoref-based specialization][0], used in [`AsRef`]/[`AsMut`] macro expansion.
//!
//! Allows tp specialize the `impl<T> AsRef<T> for T` case over the default
//! `impl<Inner: AsRef<B>, B> AsRef<B> for Outer<Inner>` one.
//!
//! [0]: https://lukaskalbertodt.github.io/2019/12/05/generalized-autoref-based-specialization.html

use core::marker::PhantomData;

/// Container to specialize over.
pub struct Conv<Frm: ?Sized, To: ?Sized>(PhantomData<(*const Frm, *const To)>);

impl<Frm: ?Sized, To: ?Sized> Default for Conv<Frm, To> {
    fn default() -> Self {
        Self(PhantomData)
    }
}

/// Trait performing the specialization.
pub trait ExtractRef {
    /// Input reference type.
    type Frm;
    /// Output reference type.
    type To;

    /// Extracts the output type from the input one.
    fn __extract_ref(&self, frm: Self::Frm) -> Self::To;
}

impl<'a, T> ExtractRef for &Conv<&'a T, T>
where
    T: ?Sized,
{
    type Frm = &'a T;
    type To = &'a T;

    fn __extract_ref(&self, frm: Self::Frm) -> Self::To {
        frm
    }
}

impl<'a, Frm, To> ExtractRef for Conv<&'a Frm, To>
where
    Frm: AsRef<To> + ?Sized,
    To: ?Sized + 'a,
{
    type Frm = &'a Frm;
    type To = &'a To;

    fn __extract_ref(&self, frm: Self::Frm) -> Self::To {
        frm.as_ref()
    }
}

impl<'a, T> ExtractRef for &Conv<&'mut T, T>
where
    T: ?Sized,
{
    type Frm = &'a mut T;
    type To = &'a mut T;

    fn __extract_ref(&self, frm: Self::Frm) -> Self::To {
        frm
    }
}

impl<'a, Frm, To> ExtractRef for Conv<&'mut Frm, To>
where
    Frm: AsMut<To> + ?Sized,
    To: ?Sized + 'a,
{
    type Frm = &'a mut Frm;
    type To = &'a mut To;

    fn __extract_ref(&self, frm: Self::Frm) -> Self::To {
        frm.as_mut()
    }
}

Messung V0.5 in Prozent
C=86 H=100 G=93

¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002