Skip to content

Deny assert!(res.is_ok()) in tests #9162

Closed
@tabokie

Description

@tabokie

What it does

It denies any form of assert!(r.is_ok()). Instead, it suggests to use r.unwrap() directly.

Lint Name

No response

Category

style

Advantage

  • In tests, using an unwrap() displays the specific offending error and helps diagnosis.

Drawbacks

No response

Example

#[test]
fn test_dummy() {
  let r = do_test();
  assert!(r.is_ok());
}

Could be written as:

#[test]
fn test_dummy() {
  do_test().unwrap();
}

Metadata

Metadata

Assignees

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions