Skip to content

Commit

Permalink
fix: assert_matches macro can only be used in nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Oct 26, 2024
1 parent 4e4c3f0 commit 2d3af86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[package]
edition = "2021"
name = "testing-in-rust"
version = "0.1.0"
edition = "2021"

[dependencies]
colored = "2"
reqwest = { version = "0.11" }
tokio = { version = "1", features = ["full"] }
warp = "0.3"
warp = "0.3"

[features]
nightly = []
3 changes: 3 additions & 0 deletions src/example07/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn function_returning_an_error(error: CustomError) -> Result<(), CustomError> {

#[cfg(test)]
mod tests {
#[cfg(feature = "nightly")]
use std::assert_matches::assert_matches;

use crate::example07::{function_returning_an_error, CustomError};
Expand All @@ -45,13 +46,15 @@ mod tests {
}

#[test]
#[cfg(feature = "nightly")]
fn test_function_returning_parse_error_with_assert_matches_macro() {
let result = function_returning_an_error(CustomError::ParseError("error".to_string()));

assert_matches!(result.unwrap_err(), CustomError::ParseError(_error));
}

#[test]
#[cfg(feature = "nightly")]
fn test_function_returning_parse_error_with_assert_matches_macro_v2() {
let result = function_returning_an_error(CustomError::ParseError("error".to_string()));

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(assert_matches)]
#![cfg_attr(feature = "nightly", feature(assert_matches))]
pub mod example01;
pub mod example02;
pub mod example03;
Expand Down

0 comments on commit 2d3af86

Please sign in to comment.