拉斯特函数默认参数 [英] Default Function Arguments in Rust

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

问题描述

是否有可能在锈创建具有默认参数的函数?

  FN加(A:INT = 1,B:INT = 2){A + B}


解决方案

没有,它不是在present,而我认为这可能是它最终会被执行,这是不太可能来到1.0之前。

在这里采用的典型的技术是不同的功能或使用不同签名的方法。

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

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

解决方案

No, it is not at present, and while I think it likely that it will eventually be implemented, it’s very unlikely to come before 1.0.

The typical technique employed here is different functions or methods with different signatures.

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

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