Skip to content
Snippets Groups Projects
Commit ca95f12c authored by Michael Hauspie's avatar Michael Hauspie
Browse files

Move impl block to test (only used in test)

parent 977017e6
No related branches found
No related tags found
No related merge requests found
Pipeline #40145 failed
......@@ -3,7 +3,6 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
pub enum Operation {
Plus(i32, i32),
......@@ -18,16 +17,6 @@ pub struct OperationResult {
resultat: i32,
}
impl OperationResult {
/// Creates a new operation result from a [`&str`] and a value.
pub fn new(s: &str, value: i32) -> Self {
Self {
operation: String::from(s),
resultat: value,
}
}
}
impl From<&Operation> for OperationResult {
fn from(value: &Operation) -> Self {
match value {
......@@ -57,11 +46,20 @@ impl From<Operation> for OperationResult {
}
}
#[cfg(test)]
mod tests {
use super::*;
impl OperationResult {
/// Creates a new operation result from a [`&str`] and a value.
pub fn new(s: &str, value: i32) -> Self {
Self {
operation: String::from(s),
resultat: value,
}
}
}
#[test]
fn plus() {
let operation = Operation::Plus(4, 5);
......@@ -97,5 +95,4 @@ mod tests {
assert_eq!(result, expected);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment