The current std::max_element for std::vector is as follows:
fn f42(a0: Ptr<u8>, a1: Ptr<u8>) -> Ptr<u8> {
let __count = a1.get_offset() - a0.get_offset();
let max_index = PtrValueIter::new(&a0, __count)
.enumerate()
.max_by_key(|&(_, val)| val)
.map(|(idx, _)| idx)
.unwrap_or(0);
a0 + max_index
}
According to the documentation for std::max_element, if there are multiple greatest elements, it returns the iterator to the first one of them. The current translation uses Rust's max_by_key, which returns the last element when there are multiple greatest elements.
This is also the case for vector's f94 and algorithm's f8 rules.
The current
std::max_elementforstd::vectoris as follows:According to the documentation for
std::max_element, if there are multiple greatest elements, it returns the iterator to the first one of them. The current translation uses Rust'smax_by_key, which returns the last element when there are multiple greatest elements.This is also the case for vector's
f94and algorithm'sf8rules.