Rust library
first
This is Rust standard-library source from the compiler version used in the run.
152 #[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]153 #[inline]154 #[must_use]155 pub const fn first(&self) -> Option<&T> {156 if let [first, ..] = self { Some(first) } else { None }157 }158 Aeneas declaration
Aeneas generated this declaration for a Rust library operation. Any authored model recorded for this operation is shown below.
@[rust_fun "core::slice::{[@T]}::first"]
axiom core.slice.Slice.first {T : Type} : Slice T → Result (Option T)Authored Lean model
Trellis authored this Lean model for an operation outside the mechanical extraction. Modeling choices explains its behavior and review.
import Aeneas
open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false
namespace dec2flt_model
-- [TABLET NODE: ModelSliceFirst]
def ModelSliceFirst {T : Type} (s : Slice T) : Result (Option T) :=
-- BODY
ok s.val.head?
end dec2flt_model
Source details
| Declaration | core.slice.Slice.first |
|---|---|
| File | /rustc/library/core/src/slice/mod.rs |
| Lines | 155:4–155:43 |
| Program version | Original program |