Rivoreo Source Code Repositories
src.rivoreo.one
/
compiler-explorer
/
cf28e93a3f06ef36838005d2ebe02e99d0529c3d
/
.
/
examples
/
rust
/
sum_over_array_opt.rs
blob: 094f341b781e1742c9b21c2076d7cc6d0eac2886 [
file
] [
log
] [
blame
] [
raw
]
#![
feature
(
core_intrinsics
)]
// 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
)
}