chore: rust code cleanup
This commit is contained in:
		
							parent
							
								
									b662a24e9a
								
							
						
					
					
						commit
						935891c852
					
				
					 1 changed files with 12 additions and 3 deletions
				
			
		|  | @ -489,7 +489,7 @@ impl Router { | |||
|             &start_sys, | ||||
|         )); | ||||
|         seen.insert(start_sys.id); | ||||
|         while !(queue.is_empty() || found) { | ||||
|         while !found { | ||||
|             while let Some((depth, _, sys)) = queue.pop() { | ||||
|                 if t_last.elapsed().as_millis() > 100 { | ||||
|                     t_last = Instant::now(); | ||||
|  | @ -534,6 +534,9 @@ impl Router { | |||
|                 }); | ||||
|                 // queue.reverse();
 | ||||
|             } | ||||
|             if queue.is_empty() { | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|         println!(); | ||||
| 
 | ||||
|  | @ -590,7 +593,7 @@ impl Router { | |||
|         let mut queue: Vec<(f32, usize, &System)> = Vec::new(); | ||||
|         queue.push((start_sys.distp(goal_sys), 0, &start_sys)); | ||||
|         seen.insert(start_sys.id); | ||||
|         while !(queue.is_empty() || found) { | ||||
|         while !found { | ||||
|             while let Some((_, depth, sys)) = queue.pop() { | ||||
|                 if t_last.elapsed().as_millis() > 100 { | ||||
|                     t_last = Instant::now(); | ||||
|  | @ -629,6 +632,9 @@ impl Router { | |||
|                 queue.sort_by(|a, b| fcmp(a.0, b.0).then(a.1.cmp(&b.1))); | ||||
|                 queue.reverse(); | ||||
|             } | ||||
|             if queue.is_empty() { | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|         if !found { | ||||
|             return Err(format!("No route from {} to {} found!", src_name, dst_name)); | ||||
|  | @ -820,7 +826,7 @@ impl Router { | |||
|         let mut queue_next: VecDeque<(usize, &System)> = VecDeque::new(); | ||||
|         queue.push_front((0, &start_sys)); | ||||
|         seen.insert(start_sys.id); | ||||
|         while !(queue.is_empty() || found) { | ||||
|         while !found { | ||||
|             while let Some((d, sys)) = queue.pop_front() { | ||||
|                 if sys.id == goal_sys.id { | ||||
|                     found = true; | ||||
|  | @ -877,6 +883,9 @@ impl Router { | |||
|                 ); | ||||
|             } | ||||
|             std::mem::swap(&mut queue, &mut queue_next); | ||||
|             if queue.is_empty() { | ||||
|                 break; | ||||
|             } | ||||
|             depth += 1; | ||||
|         } | ||||
|         println!(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue