Skip to content

Barsik-sus/Args-and-Kwargs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust ARGS and KWARGS

This crate allows you to use tail args and kwargs.

If you want an unknown argument size, you can simply do like this:

#[ extend_args( ARGS( <TYPE> ) ) ]
fn <FN NAME>( <IMPORTANT ARG> : <IMPORTANT ARG TYPE> ) -> <RETURN TYPE>
{
  // do something
}

And calls like this:

<FN NAME>!( <IMPORTANT VALUE>, <OTHER VALUES>, ... );

You can set as many required arguments as you need and the rest will be stored into args.

Also you can use named arguments. Do it like this:

#[ extend_args( KWARGS( <TYPE> ) ) ]
fn <FN NAME>( <IMPORTANT ARG> : <IMPORTANT ARG TYPE> ) -> <RETURN TYPE>
{
  // do something
}

This is the same to ARGS but now, lets look at how it calls:

<FN NAME>!( <IMPORTANT VALUE>, <KEY NAME> = <ARG VALUE>, ... );

And, ofcourse, you can use both of it:

#[ extend_args( ARGS( <ARGS TYPE> ), KWARGS( <KWARGS TYPE> ) ) ]
fn <FN NAME>( <IMPORTANT ARG> : <IMPORTANT ARG TYPE> ) -> <RETURN TYPE>
{
  // do something
}

Note that named and unnamed arguments are separated by ;

<FN NAME>!( <IMPORTANT VALUE>, <OTHER POS ARGS>, ... ; <KEY NAME> = <ARG VALUE>, ... );

For more examples see here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages