What does this mean?
error: type name `int` is undefined or not in scope
I am trying to compile this example:
fn minval(A: &[int]) -> int {
A.iter().fold(A[0], |u,&a| {
if a<u {a} else {u}
})
}
fn main() {
let A = [1i,2i,3i];
let min = minval(A.as_slice());
println!("{}", min);
}
There is no int
type in Rust. Rust has the following integer types:
i8
, i16
, i32
, i64
, i128
: signed integer with 8/16/32/64/128 bitsu8
, u16
, u32
, u64
, u128
: unsigned integer with 8/16/32/64/128 bitsisize
, usize
: signed/unsigned integer with pointer size (64 bit on 64 bit systems)You can learn more about this in this chapter of the Rust book.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With