Crates.io | combine_traits |
lib.rs | combine_traits |
version | 0.1.2 |
source | src |
created_at | 2023-01-02 01:55:54.464745 |
updated_at | 2023-01-02 02:08:52.42528 |
description | A Macro to create Traits wich are just a combination of existing ones. |
homepage | |
repository | https://github.com/oxydemeton/combine_traits/ |
max_upload_size | |
id | 749101 |
size | 4,310 |
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.
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 ,
.
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");