Rivoreo Source Code Repositories
src.rivoreo.one
/
compiler-explorer
/
d62ff479fe402c107decd98a921feaf00e532d18
/
.
/
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
)
}