From bdb6e0bd8b23402c7acf03c71c6e4b974bb727f0 Mon Sep 17 00:00:00 2001 From: edef Date: Thu, 16 Apr 2015 07:35:29 -0400 Subject: [PATCH] let StackSource::get_stack take &mut self --- benches/swap.rs | 2 +- examples/basic.rs | 2 +- src/os/mod.rs | 2 +- src/stack.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/benches/swap.rs b/benches/swap.rs index f072ff5..6e7c832 100644 --- a/benches/swap.rs +++ b/benches/swap.rs @@ -10,7 +10,7 @@ static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context< #[bench] fn swap(b: &mut test::Bencher) { unsafe { - let stack = lwkt::os::StackSource::get_stack(4 << 20).unwrap(); + let stack = lwkt::os::StackSource.get_stack(4 << 20).unwrap(); let mut ctx = Context::new(stack, move || { let ctx_ptr = ctx_slot; diff --git a/examples/basic.rs b/examples/basic.rs index f61f3d2..791eafd 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -7,7 +7,7 @@ static mut ctx_slot: *mut Context<'static, lwkt::os::Stack> = 0 as *mut Context< fn main() { unsafe { - let stack = lwkt::os::StackSource::get_stack(4 << 20).unwrap(); + let stack = lwkt::os::StackSource.get_stack(4 << 20).unwrap(); let mut ctx = Context::new(stack, move || { println!("it's alive!"); diff --git a/src/os/mod.rs b/src/os/mod.rs index 0ae1537..fcf24f2 100644 --- a/src/os/mod.rs +++ b/src/os/mod.rs @@ -30,7 +30,7 @@ impl stack::StackSource for StackSource { type Output = Stack; type Error = IoError; - fn get_stack(size: usize) -> Result { + fn get_stack(&mut self, size: usize) -> Result { let page_size = sys::page_size(); // round the page size up, diff --git a/src/stack.rs b/src/stack.rs index 2fb06df..60b0c3b 100644 --- a/src/stack.rs +++ b/src/stack.rs @@ -20,5 +20,5 @@ pub trait Stack { pub trait StackSource { type Output: Stack; type Error: Debug + Display = (); - fn get_stack(size: usize) -> Result; + fn get_stack(&mut self, size: usize) -> Result; }