combine_traits

Crates.iocombine_traits
lib.rscombine_traits
version0.1.2
sourcesrc
created_at2023-01-02 01:55:54.464745
updated_at2023-01-02 02:08:52.42528
descriptionA Macro to create Traits wich are just a combination of existing ones.
homepage
repositoryhttps://github.com/oxydemeton/combine_traits/
max_upload_size
id749101
size4,310
(oxydemeton)

documentation

https://docs.rs/combine_traits/latest/combine_traits/

README

combine_traits macro for rust

A combine_traits! is a single macro wich can be used to declare a new trait wich is no more than a combination of existing traits.

How to use

To create a new Trait call the macro combine_traits! with the name as the first argument. After a ; list all "sub_traits" seperated by ,.

Example:

use combine_traits::combine_traits;
use std::fmt::{Display, Debug};
combine_traits!(DisplayAndDebug; Display, Debug);
 
fn display_vs_debug<T: DisplayAndDebug>(x: T)->String {
    format!("Display:{}Debug:{:?}", x, x) }
assert_eq!(display_vs_debug(10), "Display:10Debug:10");
Commit count: 4

cargo fmt