mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 05:06:29 +00:00
Fixed clippy warnings (#90)
* Fixed clippy warnings * Fix as per review
This commit is contained in:
committed by
Lucien Greathouse
parent
26a7bb9746
commit
13a7c1ba81
@@ -100,11 +100,8 @@ impl FsWatcher {
|
||||
|
||||
thread::spawn(move || {
|
||||
info!("Watcher thread ({}) started", root_path.display());
|
||||
loop {
|
||||
match watch_rx.recv() {
|
||||
Ok(event) => handle_event(&imfs, &rbx_session, event),
|
||||
Err(_) => break,
|
||||
};
|
||||
while let Ok(event) = watch_rx.recv() {
|
||||
handle_event(&imfs, &rbx_session, event);
|
||||
}
|
||||
info!("Watcher thread ({}) stopped", root_path.display());
|
||||
});
|
||||
|
||||
@@ -108,13 +108,10 @@ impl Imfs {
|
||||
}
|
||||
}
|
||||
|
||||
match self.items.remove(path) {
|
||||
Some(ImfsItem::Directory(directory)) => {
|
||||
for child_path in &directory.children {
|
||||
self.path_removed(child_path)?;
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
if let Some(ImfsItem::Directory(directory)) = self.items.remove(path) {
|
||||
for child_path in &directory.children {
|
||||
self.path_removed(child_path)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -173,7 +170,7 @@ impl ImfsItem {
|
||||
|
||||
vfs.items.insert(path.to_path_buf(), item);
|
||||
|
||||
Ok(vfs.items.get(path).unwrap())
|
||||
Ok(&vfs.items[path])
|
||||
} else if metadata.is_dir() {
|
||||
let mut children = HashSet::new();
|
||||
|
||||
@@ -193,7 +190,7 @@ impl ImfsItem {
|
||||
|
||||
vfs.items.insert(path.to_path_buf(), item);
|
||||
|
||||
Ok(vfs.items.get(path).unwrap())
|
||||
Ok(&vfs.items[path])
|
||||
} else {
|
||||
panic!("Unexpected non-file, non-directory item");
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ pub enum Message {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MessageQueue {
|
||||
messages: RwLock<Vec<Message>>,
|
||||
message_listeners: Mutex<HashMap<ListenerId, mpsc::Sender<()>>>,
|
||||
|
||||
@@ -192,15 +192,12 @@ impl Project {
|
||||
} else if location_metadata.is_dir() {
|
||||
let with_file = start_location.join(PROJECT_FILENAME);
|
||||
|
||||
match fs::metadata(&with_file) {
|
||||
Ok(with_file_metadata) => {
|
||||
if with_file_metadata.is_file() {
|
||||
return Some(with_file);
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
},
|
||||
Err(_) => {},
|
||||
if let Ok(with_file_metadata) = fs::metadata(&with_file) {
|
||||
if with_file_metadata.is_file() {
|
||||
return Some(with_file);
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,20 +65,15 @@ impl PathIdTree {
|
||||
let root_id = root_node.id;
|
||||
let mut to_visit: Vec<PathBuf> = root_node.children.drain().collect();
|
||||
|
||||
loop {
|
||||
let next_path = match to_visit.pop() {
|
||||
Some(path) => path,
|
||||
None => break,
|
||||
};
|
||||
|
||||
match self.nodes.remove(&next_path) {
|
||||
while let Some(path) = to_visit.pop() {
|
||||
match self.nodes.remove(&path) {
|
||||
Some(mut node) => {
|
||||
for child in node.children.drain() {
|
||||
to_visit.push(child);
|
||||
}
|
||||
},
|
||||
None => {
|
||||
warn!("Consistency issue; tried to remove {} but it was already removed", next_path.display());
|
||||
warn!("Consistency issue; tried to remove {} but it was already removed", path.display());
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -203,7 +198,7 @@ fn construct_initial_tree(
|
||||
construct_project_node(
|
||||
&mut context,
|
||||
None,
|
||||
project.name.clone(),
|
||||
&project.name,
|
||||
&project.name,
|
||||
&project.tree,
|
||||
);
|
||||
@@ -231,7 +226,7 @@ fn insert_or_create_tree(context: &mut ConstructContext, parent_instance_id: Opt
|
||||
fn construct_project_node(
|
||||
context: &mut ConstructContext,
|
||||
parent_instance_id: Option<RbxId>,
|
||||
instance_path: String,
|
||||
instance_path: &str,
|
||||
instance_name: &str,
|
||||
project_node: &ProjectNode,
|
||||
) {
|
||||
@@ -264,7 +259,7 @@ fn construct_instance_node(
|
||||
|
||||
for (child_name, child_project_node) in &project_node.children {
|
||||
let child_path = format!("{}/{}", instance_path, child_name);
|
||||
construct_project_node(context, Some(id), child_path, child_name, child_project_node);
|
||||
construct_project_node(context, Some(id), &child_path, child_name, child_project_node);
|
||||
}
|
||||
|
||||
id
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct Session {
|
||||
pub session_id: SessionId,
|
||||
pub message_queue: Arc<MessageQueue>,
|
||||
pub rbx_session: Arc<Mutex<RbxSession>>,
|
||||
fs_watcher: FsWatcher,
|
||||
_fs_watcher: FsWatcher,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
@@ -44,7 +44,7 @@ impl Session {
|
||||
session_id,
|
||||
message_queue,
|
||||
rbx_session,
|
||||
fs_watcher,
|
||||
_fs_watcher: fs_watcher,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ pub struct Server {
|
||||
impl Server {
|
||||
pub fn new(session: Arc<Session>) -> Server {
|
||||
Server {
|
||||
session: session,
|
||||
session,
|
||||
server_version: env!("CARGO_PKG_VERSION"),
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ impl Server {
|
||||
{
|
||||
let (new_cursor, new_messages) = message_queue.get_messages_since(cursor);
|
||||
|
||||
if new_messages.len() > 0 {
|
||||
if !new_messages.is_empty() {
|
||||
return Response::json(&SubscribeResponse {
|
||||
session_id: self.session.session_id,
|
||||
messages: Cow::Borrowed(&[]),
|
||||
@@ -129,7 +129,7 @@ impl Server {
|
||||
let message_queue = Arc::clone(&self.session.message_queue);
|
||||
|
||||
let requested_ids: Option<Vec<RbxId>> = id_list
|
||||
.split(",")
|
||||
.split(',')
|
||||
.map(RbxId::parse_str)
|
||||
.collect();
|
||||
|
||||
@@ -146,15 +146,12 @@ impl Server {
|
||||
let mut instances = HashMap::new();
|
||||
|
||||
for &requested_id in &requested_ids {
|
||||
match tree.get_instance(requested_id) {
|
||||
Some(instance) => {
|
||||
instances.insert(instance.get_id(), Cow::Borrowed(instance));
|
||||
if let Some(instance) = tree.get_instance(requested_id) {
|
||||
instances.insert(instance.get_id(), Cow::Borrowed(instance));
|
||||
|
||||
for descendant in tree.descendants(requested_id) {
|
||||
instances.insert(descendant.get_id(), Cow::Borrowed(descendant));
|
||||
}
|
||||
},
|
||||
None => {},
|
||||
for descendant in tree.descendants(requested_id) {
|
||||
instances.insert(descendant.get_id(), Cow::Borrowed(descendant));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user