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

Quelle  from_str.rs

  Sprache: Rust
 

#![cfg_attr(not(feature = "std"), no_std)]
#![allow(dead_code)] // some code is tested for type checking only

#[cfg(not(feature = "std"))]
extern crate alloc;

#[cfg(not(feature = "std"))]
use alloc::string::ToString;

use derive_more::FromStr;

#[derive(FromStr)]
struct MyInt(i32);

#[derive(FromStr)]
struct Point1D {
    x: i32,
}

/// Making sure that `FromStr` does not trigger an ambiguous associated item error for `Err`.
#[derive(FromStr)]
enum EnumWithErr {
    Err,
}

#[derive(Debug, FromStr, PartialEq, Eq)]
enum EnumNoFields {
    Foo,
    Bar,
    Baz,
    BaZ,
}

#[test]
fn enum_test() {
    assert_eq!("Foo".parse::<EnumNoFields>().unwrap(), EnumNoFields::Foo);
    assert_eq!("FOO".parse::<EnumNoFields>().unwrap(), EnumNoFields::Foo);
    assert_eq!("foo".parse::<EnumNoFields>().unwrap(), EnumNoFields::Foo);
    assert_eq!(
        "other".parse::<EnumNoFields>().unwrap_err().to_string(),
        "Invalid `EnumNoFields` string representation",
    );
}

#[test]
fn enum_test_case_sensitive() {
    assert_eq!("Baz".parse::<EnumNoFields>().unwrap(), EnumNoFields::Baz);
    assert_eq!("BaZ".parse::<EnumNoFields>().unwrap(), EnumNoFields::BaZ);
    assert_eq!(
        "baz".parse::<EnumNoFields>().unwrap_err().to_string(),
        "Invalid `EnumNoFields` string representation",
    );
}

Messung V0.5 in Prozent
C=99 H=95 G=96

¤ Dauer der Verarbeitung: 0.2 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.