Rivoreo Source Code Repositories
src.rivoreo.one
/
compiler-explorer
/
d92ef4f2b6312e0df03f2b0fdc72f1eba7cbcfcb
/
.
/
examples
/
rust
/
Sum_over_array_(Optimized).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
)
}