Rust library
split_first
This is Rust standard-library source from the compiler version used in the run.
195 #[rustc_const_stable(feature = "const_slice_first_last_not_mut", since = "1.56.0")]196 #[inline]197 #[must_use]198 pub const fn split_first(&self) -> Option<(&T, &[T])> {199 if let [first, tail @ ..] = self { Some((first, tail)) } else { None }200 }201 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]}::split_first"]
axiom core.slice.Slice.split_first
{T : Type} : Slice T → Result (Option (T × (Slice 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: ModelSliceSplitFirst]
def ModelSliceSplitFirst {T : Type}
(s : Slice T) : Result (Option (T × Slice T)) :=
-- BODY
match h : s.val with
| [] => ok none
| x :: xs => ok (some (x, ⟨xs, by
have p := s.property
rw [h] at p
have p' : 1 + xs.length ≤ Usize.max := by
simpa [Nat.add_comm] using p
exact Nat.le_trans (Nat.le_add_left xs.length 1) p'⟩))
end dec2flt_model
Source details
| Declaration | core.slice.Slice.split_first |
|---|---|
| File | /rustc/library/core/src/slice/mod.rs |
| Lines | 198:4–198:57 |
| Program version | Original program |