Function konst::option::copied

source ·
pub const fn copied<T: Copy>(opt: Option<&T>) -> Option<T>
Expand description

A const equivalent of the Option::copied method.

§Example

use konst::option;

const fn get_last(slice: &[u64]) -> Option<u64> {
    option::copied(slice.last())
}

assert_eq!(get_last(&[]), None);
assert_eq!(get_last(&[16]), Some(16));
assert_eq!(get_last(&[3, 5, 8, 13]), Some(13));