-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a4973c
commit 6d697e3
Showing
18 changed files
with
46 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
use mit::models::Index; | ||
|
||
mod cli; | ||
mod commands; | ||
mod models; | ||
mod utils; | ||
|
||
fn main() { | ||
color_backtrace::install(); // colorize backtrace | ||
cli::handle_command(); | ||
Index::get_instance().save(); //兜底save | ||
models::Index::get_instance().save(); //兜底save | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
pub mod util; | ||
pub mod head; | ||
pub mod store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +0,0 @@ | ||
use mit::utils::util; | ||
use sha1::{Digest, Sha1}; | ||
use std::fs::File; | ||
use std::io::{BufRead, BufReader, Error, Write}; | ||
|
||
#[test] | ||
fn test_hash() { | ||
let mut hasher = Sha1::new(); | ||
hasher.update(String::from("hello world")); | ||
let result = format!("{:x}", hasher.finalize()); | ||
println!("{}", result); | ||
println!("{}", util::calc_hash(&String::from("hello world"))); | ||
} | ||
|
||
#[test] | ||
fn test_write() -> Result<(), Error> { | ||
util::setup_test_with_clean_mit(); | ||
let path = "lines.txt"; | ||
//create会截断文件 | ||
let mut output = File::create(path)?; // ? 用于传播错误 | ||
write!(output, "Rust\nWrite\nRead4")?; | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_read() -> Result<(), Error> { | ||
util::setup_test_with_clean_mit(); | ||
let path = "lines.txt"; | ||
util::ensure_test_file(path.as_ref(), None); | ||
let input = File::open(path)?; | ||
let buffered = BufReader::new(input); | ||
|
||
for line in buffered.lines() { | ||
println!("{}", line?); | ||
} | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_string() { | ||
let mut s = String::from("Hello"); | ||
s.push_str(", world!"); | ||
s += "2"; | ||
s.push('!'); | ||
println!("{}", s); | ||
} | ||