macron-impl-from

Crates.iomacron-impl-from
lib.rsmacron-impl-from
version0.1.1
created_at2025-04-06 14:59:31.792932+00
updated_at2025-05-25 04:17:06.418181+00
descriptionThe implementation of trait From
homepage
repositoryhttps://github.com/fuderis/rs-macron/tree/main/macron-impl-from
max_upload_size
id1622977
size12,056
Bulat Sh. (fuderis)

documentation

README

githubcrates-iodocs-rs

Impl From Macro

Introduction:

The implementation of trait From.

P.s.: More useful macros you can find here.

Examples:

#[derive(From, Debug, PartialEq)]
#[from(Insertion, "Self { insertion: value }")]
struct Test {
    insertion: Insertion,
}

#[derive(Debug, PartialEq)]
struct Insertion;

assert_eq!(Test { insertion: Insertion {} }, Test::from(Insertion {}));
#[derive(From, Debug, PartialEq)]
#[from(Insertion, "Self::Insertion(value)")]
enum Test {
    Insertion(Insertion),

    #[from(Insertion2, "value")]
    Insertion2(Insertion2),

    #[from(Insertion3, "insertion: value")]
    Insertion3 { insertion: Insertion3 },

    #[from]
    Insertion4(Insertion4),

    #[from]
    Insertion5 { insertion: Insertion5 },
}

#[derive(Debug, PartialEq)]
struct Insertion;

#[derive(Debug, PartialEq)]
struct Insertion2;

#[derive(Debug, PartialEq)]
struct Insertion3;

#[derive(Debug, PartialEq)]
struct Insertion4;

#[derive(Debug, PartialEq)]
struct Insertion5;

assert_eq!(Test::Insertion(Insertion {}), Test::from(Insertion {}));
assert_eq!(Test::Insertion2(Insertion2 {}), Test::from(Insertion2 {}));
assert_eq!(Test::Insertion3 { insertion: Insertion3 {} }, Test::from(Insertion3 {}));
assert_eq!(Test::Insertion4(Insertion4 {}), Test::from(Insertion4 {}));
assert_eq!(Test::Insertion5 { insertion: Insertion5 {} }, Test::from(Insertion5 {}));

Licensing:

Distributed under the MIT license.

Feedback:

You can contact me via GitHub or send a message to my Telegram @fuderis.

This library is constantly evolving, and I welcome your suggestions and feedback.

Commit count: 15

cargo fmt