【发布时间】:2016-08-10 22:13:16
【问题描述】:
在以下代码中,如何返回floor 的引用而不是新对象?是否可以让函数返回借用的引用或拥有的值?
extern crate num; // 0.2.0
use num::bigint::BigInt;
fn cal(a: BigInt, b: BigInt, floor: &BigInt) -> BigInt {
let c: BigInt = a - b;
if c.ge(floor) {
c
} else {
floor.clone()
}
}
【问题讨论】: