I am going to demonstrate a small piece of code:
in Cargo.toml:
[dependencies]
num = "0.1.32"
in main.rs:
exte crate num;
use num::bigint::{BigInt, ToBigInt};
fn cal(a: BigInt, b: BigInt, floor: &BigInt) -> BigInt {
let c : BigInt = a- b ;
if c .ge( floor ) {
c
} else {
floor.clone()
}
}
My questions is, how can I retu the reference of floor instead of the a new object? Is it possible let the function retu borrowed reference or ownership? Thanks!
