Lifetime bound required help

i try to use windows api write a windows GUI program, use thread_local to save all created window or button.

use std::thread::Thread;
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::HashMap;

trait Wnd{

  fn CreateWindow(&self)->int
  {
     // do some thing
    0
  }
}

pub struct Dust{
  window_counter:int,
  hInstance:int,
  hookId: int,
  widgets:HashMap<int, Rc<RefCell<Wnd>>>,
}

fn dust()->RefCell<Dust>{
  unsafe{
    let mut d = Dust{
      window_counter:0,
      hInstance:0,
      hookId:0,
      widgets: HashMap::new(),
    };
    
    return RefCell::new(d)
  }
}

pub thread_local!(static TLS_DUST: RefCell<Dust> = dust());


fn main()
{

    TLS_DUST.with( | d | {
        let mut dust = d.borrow_mut();
        dust.window_counter-=1;
    });
        
}

i got the error:

error: explicit lifetime bound required
error: aborting due to previous error

This question belongs to stackoverflow. See this post: http://discuss.rust-lang.org/t/about-this-forum-please-read/6

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.