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

Quelle  examples.rs

  Sprache: Rust
 

// vim: tw=80
//! Examples of Mockall's generated code
use mockall::{mock, automock};

/// Mock of a basic trait with several kinds of method.
///
/// It is mocked by the [`MockFoo`](struct.MockFoo.html) struct.
#[automock]
pub trait Foo {
    /// A method with a `'static` return type
    fn foo(&self, x: i32, y: i16) -> i32;

    /// A method returning a reference
    fn bar(&self, x: i32) -> &i32;

    /// A method returning a mutable reference
    fn baz(&mut self, x: i32) -> &mut i32;

    /// A method returning a `'static` reference
    fn bean(&self) -> &'static i32;

    /// A static method
    fn bang(x: i32) -> i32;
}

/// A trait implemented by a Struct we want to mock
pub trait Bah {
    /// Some trait method
    fn bah(&self);
}

mock! {
    /// Mock of a struct
    ///
    /// Structs can be mocked with [`mock!`].
    /// Their mock methods have an identical API to the methods generated by
    /// [`#[automock]`](automock).
    pub Boo {
        /// A method on a struct
        fn boo(&self);
    }
    /// An implementation of a trait on a mocked struct
    impl Bah for Boo {
        fn bah(&self);
    }
}

/// A module full of foreign C functions.
#[automock]
pub mod ffi {
    extern "C" {
        /// A foreign "C" function.
        pub fn ffi_func();
    }
}

/// Mock this entire module
#[automock]
pub mod my_module {
    /// A function in a mocked module
    pub fn modfunc() {
        unimplemented!()
    }
}

Messung V0.5 in Prozent
C=92 H=98 G=94

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