Thanks for using Compiler Explorer
Sponsors
C++
Ada
Analysis
Assembly
C
C++ (Circle)
Clean
CMake
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Crystal
C#
CUDA C++
D
Dart
Erlang
Fortran
F#
Go
Haskell
ispc
Java
Kotlin
LLVM IR
Nim
OCaml
OpenCL C
Pascal
Python
Ruby
Rust
Scala
Solidity
Swift
Toit
TypeScript Native
Visual Basic
Zig
rust source #1
Output
Compile to binary
Execute the code
Intel asm syntax
Demangle identifiers
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Compiler
gccrs-snapshot
mrustc-master
rustc 1.0.0
rustc 1.1.0
rustc 1.10.0
rustc 1.11.0
rustc 1.12.0
rustc 1.13.0
rustc 1.14.0
rustc 1.15.1
rustc 1.16.0
rustc 1.17.0
rustc 1.18.0
rustc 1.19.0
rustc 1.2.0
rustc 1.20.0
rustc 1.21.0
rustc 1.22.0
rustc 1.23.0
rustc 1.24.0
rustc 1.25.0
rustc 1.26.0
rustc 1.27.0
rustc 1.27.1
rustc 1.28.0
rustc 1.29.0
rustc 1.3.0
rustc 1.30.0
rustc 1.31.0
rustc 1.32.0
rustc 1.33.0
rustc 1.34.0
rustc 1.35.0
rustc 1.36.0
rustc 1.37.0
rustc 1.38.0
rustc 1.39.0
rustc 1.4.0
rustc 1.40.0
rustc 1.41.0
rustc 1.42.0
rustc 1.43.0
rustc 1.44.0
rustc 1.45.0
rustc 1.45.2
rustc 1.46.0
rustc 1.47.0
rustc 1.48.0
rustc 1.49.0
rustc 1.5.0
rustc 1.50.0
rustc 1.51.0
rustc 1.52.0
rustc 1.53.0
rustc 1.54.0
rustc 1.55.0
rustc 1.56.0
rustc 1.57.0
rustc 1.58.0
rustc 1.59.0
rustc 1.6.0
rustc 1.60.0
rustc 1.61.0
rustc 1.62.0
rustc 1.7.0
rustc 1.8.0
rustc 1.9.0
rustc beta
rustc nightly
rustccggcc-master
Options
Source code
#![allow(incomplete_features)] #![feature(const_generics, const_evaluatable_checked)] /// Like `MaybeUninit<[u8; N]>`, but always considered uninitialized. /// /// You might want this if you want to surround fields with padding, /// without impacting the alignment of the struct containing the /// field (the way that use of an `#[repr(align(N))]` would). #[repr(transparent)] #[derive(Clone, Copy)] pub struct AlwaysUninit<const N: usize>( core::mem::MaybeUninit<[OveralignedU8; (N + 7) / 8]> ) where [(); (N + 7) / 8]: Sized; // an alignment of 8 is small enough as to not generally // matter much in practice #[repr(C, align(8))] #[derive(Clone, Copy)] struct OveralignedU8(u8); const _: [(); 1] = [(); ( core::mem::size_of::<AlwaysUninit<64>>() >= 64 ) as usize]; #[repr(C)] #[derive(Clone)] pub struct Example { _pad0: AlwaysUninit<64>, v0: core::cell::Cell<usize>, _pad1: AlwaysUninit<64>, v1: usize, _pad2: AlwaysUninit<64>, } pub fn can_we_copy_efficiently(c: &Example) -> Example { c.clone() }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
About the author
Changelog
Version tree