libfringe/src/stack.rs

22 lines
657 B
Rust
Raw Normal View History

2015-04-16 11:37:17 +08:00
//! Traits for stacks.
use core::prelude::*;
2015-04-16 11:37:17 +08:00
/// A trait for objects that hold ownership of a stack.
pub trait Stack {
2015-04-16 11:37:17 +08:00
/// Returns the top of the stack.
/// On all modern architectures, the stack grows downwards,
/// so this is the highest address.
fn top(&mut self) -> *mut u8;
2015-04-16 11:37:17 +08:00
/// Returns the bottom of the stack.
/// On all modern architectures, the stack grows downwards,
/// so this is the lowest address.
fn limit(&self) -> *const u8;
2014-12-23 11:24:40 +08:00
}
2015-04-16 11:37:17 +08:00
/// A trait for objects that provide stacks of arbitrary size.
pub trait StackSource {
type Output: Stack;
type Error = ();
fn get_stack(size: usize) -> Result<Self::Output, Self::Error>;
}