Rivoreo Source Code Repositories
src.rivoreo.one
/
compiler-explorer
/
56a691d02328cd4cf972d2e68eba1f1d101f344a
/
.
/
examples
/
rust
/
sum_over_array_opt.rs
blob: e9e9afc8ef9960e0be2ac68dc256f005d4bc11e8 [
file
] [
log
] [
blame
] [
raw
]
#![
feature
(
core
)]
// Requires the use of the nightly rust
// Compile with -O
pub
fn
sum_array
(
x
:
&[
i32
])
->
i32
{
unsafe
{
std
::
intrinsics
::
assume
(
x
.
as_ptr
()
as
usize
%
64
==
0
);
}
x
.
iter
().
fold
(
0
,
|
sum
,
next
|
sum
+
*
next
)
}