Run rustfmt on all rs files

This commit is contained in:
Felix Martin 2020-12-03 19:52:15 -05:00
parent 778b665ae0
commit b31fe7176c
5 changed files with 118 additions and 114 deletions

View File

@ -1,16 +1,17 @@
mod merge_sort; mod merge_sort;
mod min_cut;
mod quick_sort; mod quick_sort;
mod ssc; mod ssc;
mod min_cut;
mod util; mod util;
use crate::util::read_to_graph; use crate::util::read_to_graph;
use crate::util::read_to_directed_graph;
use crate::util::read_to_vector; use crate::merge_sort::merge_sort_inversions;
use crate::min_cut::min_cut; use crate::min_cut::min_cut;
use crate::quick_sort::quick_sort; use crate::quick_sort::quick_sort;
use crate::merge_sort::merge_sort_inversions;
use crate::ssc::ssc; use crate::ssc::ssc;
use crate::util::read_to_directed_graph;
use crate::util::read_to_vector;
#[allow(dead_code)] #[allow(dead_code)]
fn c1a2() { fn c1a2() {

View File

@ -1,5 +1,5 @@
use rand::Rng;
use crate::util::Graph; use crate::util::Graph;
use rand::Rng;
use std::convert::TryInto; use std::convert::TryInto;
pub fn min_cut(mut g: Graph) -> u32 { pub fn min_cut(mut g: Graph) -> u32 {

View File

@ -1,6 +1,5 @@
use std::cmp::PartialOrd; use std::cmp::PartialOrd;
fn median_of_three<T: PartialOrd + Copy>(v: &[T]) -> usize { fn median_of_three<T: PartialOrd + Copy>(v: &[T]) -> usize {
if v.len() < 3 { if v.len() < 3 {
return 0; return 0;
@ -30,7 +29,7 @@ fn median_of_three<T: PartialOrd + Copy>( v: &[T]) -> usize {
fn bubble_sort<T: PartialOrd>(v: &mut [T]) -> () { fn bubble_sort<T: PartialOrd>(v: &mut [T]) -> () {
let mut unsorted = true; let mut unsorted = true;
if v.len() <= 1 { if v.len() <= 1 {
return return;
} }
while unsorted { while unsorted {
unsorted = false; unsorted = false;
@ -41,7 +40,6 @@ fn bubble_sort<T: PartialOrd>( v: &mut [T]) -> () {
} }
} }
} }
} }
pub fn quick_sort<T: PartialOrd + Copy>(v: &mut [T], comp_acc: &mut usize) -> () { pub fn quick_sort<T: PartialOrd + Copy>(v: &mut [T], comp_acc: &mut usize) -> () {

View File

@ -24,9 +24,11 @@ pub fn read_to_vector(path: &str) -> Result<Vec<i64>, io::Error> {
Ok(v) Ok(v)
} }
pub fn read_to_graph(path: &str) -> Result<Graph, io::Error> { pub fn read_to_graph(path: &str) -> Result<Graph, io::Error> {
let mut g = Graph { nodes: vec![], edges: vec![] }; let mut g = Graph {
nodes: vec![],
edges: vec![],
};
let file = File::open(path)?; let file = File::open(path)?;
let br = BufReader::new(file); let br = BufReader::new(file);
@ -51,7 +53,10 @@ pub fn read_to_graph(path: &str) -> Result<Graph, io::Error> {
} }
pub fn read_to_directed_graph(path: &str) -> Result<Graph, io::Error> { pub fn read_to_directed_graph(path: &str) -> Result<Graph, io::Error> {
let mut g = Graph { nodes: vec![], edges: vec![] }; let mut g = Graph {
nodes: vec![],
edges: vec![],
};
let file = File::open(path)?; let file = File::open(path)?;
let br = BufReader::new(file); let br = BufReader::new(file);