Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is Python's *Args and **kwargs equivalent in Rust

What is Python’s *Args and **kwargs equivalent in Rust

def main(*args, **kwargs):
  pass

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Those are variadic arguments and Rust has no direct equivalent. This is because Rust is extremely strongly typed and must know exactly what types will be passed to a function.

Depending on what you’re doing, you’d probably define a function that takes collections; Vec for *args and HashMap for **kwargs. But everything in each collection must be of the same type; a Vec of integers, a HashMap of pairs of strings, etc.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading