From 8d38596e238bac4ba91589b06222eeb2f10f44e0 Mon Sep 17 00:00:00 2001 From: "fupan.lfp" Date: Wed, 30 Jun 2021 17:41:25 +0800 Subject: [PATCH] freezer: fix the issue of missing trim the str When reading from the freezer file, it should trim it first, and the string may container an '\n'. Fixes: #48 Signed-off-by: fupan.lfp --- src/freezer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freezer.rs b/src/freezer.rs index 7f0fc1c9..1ced04da 100644 --- a/src/freezer.rs +++ b/src/freezer.rs @@ -130,7 +130,7 @@ impl FreezerController { let mut s = String::new(); let res = file.read_to_string(&mut s); match res { - Ok(_) => match s.as_ref() { + Ok(_) => match s.trim().as_ref() { "FROZEN" => Ok(FreezerState::Frozen), "THAWED" => Ok(FreezerState::Thawed), "1" => Ok(FreezerState::Frozen),