相关疑难解决方法(0)

在结构中借用参考

我正在尝试将一个关于inotify事件和hashmap的结构信息与inotify watch id作为键和文件名作为值.

extern crate inotify;
use inotify::INotify;
use std::sync::{Arc, Mutex};
use std::collections::HashMap;

struct Notificator {
    inotify: INotify,
    watch_service: Arc<Mutex<HashMap<inotify::wrapper::Watch, Arc<String>>>>,
}

impl Notificator {
    pub fn new() -> Notificator {
        Notificator {
            inotify: INotify::init().unwrap(),
            watch_service: Arc::new(Mutex::new(HashMap::new())),
        }
    }

    pub fn resolving_events(&mut self) {
        {
            let mut events = self.check_for_events();
            self.events_execution(events);
        }

    }

    fn check_for_events(&mut self) -> &[inotify::wrapper::Event] {
        self.inotify.available_events().unwrap()
    }

    fn events_execution(&self, events: &[inotify::wrapper::Event]) {
        for event in events.iter() {

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在编译期间,我收到一个错误

src/main.rs:204:13: 204:17 error: cannot borrow …
Run Code Online (Sandbox Code Playgroud)

rust

4
推荐指数
2
解决办法
547
查看次数

标签 统计

rust ×1