Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/objc2-foundation/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  util.rs

  Sprache: Rust
 

#![allow(dead_code)]
use core::{fmt, ptr::NonNull};

use objc2::runtime::__nsstring::nsstring_to_str;
use objc2::{
    rc::{autoreleasepool_leaking, Retained},
    runtime::NSObject,
};

pub(cratefn retained_ptr_cast<T: ?Sized>(objects: *mut Retained<T>) -> *mut NonNull<T> {
    // SAFETY: `Retained<T>` has the same memory layout as `NonNull<T>`, and
    // stronger guarantees.
    objects.cast()
}

pub(cratefn ref_ptr_cast_const<T: ?Sized>(objects: *const &T) -> *mut NonNull<T> {
    // SAFETY: `&T` has the same memory layout as `NonNull<T>`, and stronger
    // guarantees.
    (objects as *mut &T).cast()
}

pub(cratefn retained_ptr_cast_const<T: ?Sized>(objects: *const Retained<T>) -> *mut NonNull<T> {
    retained_ptr_cast(objects as *mut Retained<T>)
}

/// Display the string.
///
/// Put here to allow using it without the `"NSString"` feature being active.
///
/// # Safety
///
/// The string must be an instance of `NSString`.
pub(crateunsafe fn display_string(string: &NSObject, f: &mut fmt::Formatter<'_>) -> fmt::Result {
    // SAFETY:
    // - The caller upholds that the object is a `NSString`.
    // - We control the scope in which the string is alive, so we know
    //   it is not moved outside the current autorelease pool.
    //
    // TODO: Use more performant APIs, maybe by copying bytes into a
    // temporary stack buffer so that we avoid allocating?
    //
    // Beware though that the string may be mutable internally, and that
    // mutation may happen on every call to the formatter `f` (so
    // `CFStringGetCharactersPtr` is probably out of the question, unless we
    // somehow check that the string is immutable?).
    autoreleasepool_leaking(|pool| fmt::Display::fmt(unsafe { nsstring_to_str(string, pool) }, f))
}

Messung V0.5 in Prozent
C=64 H=83 G=73

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

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