Default function arguments in Rust

前端 未结 6 458
时光取名叫无心
时光取名叫无心 2020-12-13 05:38

Is it possible in Rust to create a function with a default argument?

fn add(a: int = 1, b: int = 2) { a + b }
6条回答
  •  既然无缘
    2020-12-13 05:44

    No, it is not at present. I think it likely that it will eventually be implemented, but there’s no active work in this space at present.

    The typical technique employed here is to use functions or methods with different names and signatures.

提交回复
热议问题