Rust 中的默认函数参数 [英] Default function arguments in Rust

查看:31
本文介绍了Rust 中的默认函数参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建带有默认参数的函数?

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

fn add(a: int = 1, b: int = 2) { a + b }

推荐答案

不,目前没有.我认为它最终可能会实施,但目前在这方面没有积极的工作.

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.

这篇关于Rust 中的默认函数参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆