Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

README.md

cargo-strict

check unwrap strict code.

Instllation

$ cargo install --git https://github.com/hhatto/cargo-strict.git

Usage

$ cargo strict

input:

$ cat examples/simple.rs
fn main() {
    let s = "Hello world";  /* .unwrap() */
    let _ = s.find("wo").unwrap();
    // let _ = s.find("wo").unwrap();
    let ignore = "s.unwrap();";
}

Usage as linter

$ cargo strict
./examples/simple.rs:2:24:     let _ = s.find("wo").unwrap();
./src/main.rs:96:36:     let input = File::open(filename).unwrap();
$ cargo strict example/simple.rs
./examples/simple.rs:2:24:     let _ = s.find("wo").unwrap();

Usage as formatter

$ cargo strict --fix
$ git diff
diff --git a/examples/simple.rs b/examples/simple.rs
index e066898..dbe188b 100644
--- a/examples/simple.rs
+++ b/examples/simple.rs
@@ -1,6 +1,6 @@
 fn main() {
     let s = "Hello world";  /* .unwrap() */
-    let _ = s.find("wo").unwrap();
+    let _ = s.find("wo").expect("error-id:5cb0410ba34b040dbbde09dc1991685d");
     // let _ = s.find("wo").unwrap();
     let ignore = "s.unwrap();";
 }

About

avoid unwrap() method

Topics

Resources

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.