Skip to content

Latest commit

 

History

History
 
 

variadic_from

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Module :: variadic_from

experimental rust-status docs.rs Open in Gitpod discord

Variadic from

Basic use-case.

use variadic_from::exposed::*;

fn main()
{
  #[ derive( Debug, PartialEq, Default, VariadicFrom ) ]
  struct StructNamedFields
  {
    a : i32,
    b : i32,
  }

  let got : StructNamedFields = From::from( ( 13, 14 ) );
  let exp = StructNamedFields{ a : 13, b : 14 };
  assert_eq!( got, exp );

  let got : StructNamedFields = from!( 13, 14 );
  let exp = StructNamedFields{ a : 13, b : 14 };
  assert_eq!( got, exp );

  let got : StructNamedFields = ( 13, 14 ).to();
  let exp = StructNamedFields{ a : 13, b : 14 };
  assert_eq!( got, exp );

}

To add to your project

cargo add variadic_from

Try out from the repository

git clone https://github.com/Wandalen/wTools
cd wTools
cargo run --example variadic_from_trivial