Trait StackResult
pub trait StackResult: List + CStackListHeadLimit {
// Required method
unsafe fn take_result(stack: &mut RawStack) -> Self::Head;
}Expand description
Extracts a canonical typed segment’s result or its empty-stack marker.
The sealed layout requirement prevents foreign list implementations from substituting unchecked stack representation metadata.
§Examples
use cel_runtime::{Segment, SegmentCallable};
assert!(Segment::<()>::new().call(()).is_ok());Required Methods§
unsafe fn take_result(stack: &mut RawStack) -> Self::Head
unsafe fn take_result(stack: &mut RawStack) -> Self::Head
Moves the final result out, or returns the empty-stack marker.
- Complexity: O(s + p) time for s head bytes and p head-padding bytes; O(s) result storage.
§Examples
use cel_runtime::{CStackList, CNil, RawStack, StackResult};
type ResultStack = CStackList<String, CNil<()>>;
let mut stack = RawStack::with_base_alignment(align_of::<String>());
stack.push(String::from("moved"));
let result = unsafe { ResultStack::take_result(&mut stack) };
assert_eq!(result, "moved");
assert_eq!(stack.len(), 0);§Safety
The raw stack’s live values must match this type-level stack exactly.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".