나는 inotify 이벤트와 해시 맵에 대한 구조 정보를 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() {
}
}
}
나는
src/main.rs:204:13: 204:17 error: cannot borrow `*self` as immutable because it is also borrowed as mutable [E0502]
src/main.rs:204 self.events_execution(events);
내가 가장 좋은 방법은 watch_service와 Notificator 구조에 어떻게 든 inotify를 변수를 분리하는 것이라고 생각 오류를 받고 있어요,하지만 난
self.check_for_events();
역 참조 나는
를받을 수 없기 때문에
src/main.rs:203:17: 203:27 error: the trait bound `[inotify::wrapper::Event]: std::marker::Sized` is not satisfied [E0277]
src/main.rs:203 let mut events = *self.check_for_events();
나는이 문제의 핵심을 이해하고있다. 나는 check_for_events
을 참조하여 매개 변수로 사용하려고한다. events_execution
또한 매개 변수로 self
이 필요하지만이를 해결하는 방법을 알지 못합니다.
'self' 이벤트 실행에서? 그렇지 않은 경우 매개 변수로 사용하지 않으면 문제가 해결 될 수 있습니다. – Noctua
@Noctua, 나는 글쓰기를 잊어 버렸지 만 네, 저는 이벤트 실행에 자신을 사용하고 있습니다. – m0drzew