From 9c237d8681613059f86cd8f13e1da3b9a0b6a47a Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Fri, 10 Oct 2025 12:42:14 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(eol=5Faction):=20add=20parse?= =?UTF-8?q?=20method=20to=20EolAction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - implement `parse` method for `EolAction` to convert strings to `EolAction` variants - support "trash" and "delete" strings, return `None` for others --- src/eol_action.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/eol_action.rs b/src/eol_action.rs index e90bd74..a971b41 100644 --- a/src/eol_action.rs +++ b/src/eol_action.rs @@ -20,3 +20,14 @@ impl fmt::Display for EolAction { } } } + +impl EolAction { + /// Parse a string to a valid `EolAction` variant or return `None`. + pub fn parse(str: &str) -> Option { + match str.to_lowercase().as_str() { + "trash" => Some(EolAction::Trash), + "delete" => Some(EolAction::Delete), + _ => None, + } + } +}