Is it possible to define optional arguments within functions in Rust? -


Whether correction allows for alternative function arguments, which I can set to some default value, such as pattern matching or Some other mechanisms?

Not technically, but you can close the option enum Always available to get the same effect:

  fn opt_arg (i: option ) {match i {some (x) = & gt; {Println! ("Understand {}", x); }, None = & gt; {Println! ("Nothing found"); }}} Fn Main () {opt_arg (none); // none found the opt_group (some (2i)); // got 2}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -