Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "caesar_cipher_enc_dec"
version = "1.0.3"
version = "1.0.4"
edition = "2021"
description = "can easily use caesar cipher"
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions src/caesar_cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl std::fmt::Display for CipherError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
CipherError::InvalidShift(msg) => write!(f, "Invalid shift value: {}", msg),
CipherError::EmptyText => write!(f, "Input text cannot be empty"),
CipherError::EmptyText => write!(f, "Input text cannot be empty or whitespace-only"),
}
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn decrypt(text: &str, shift: i16) -> String {
/// assert!(encrypt_safe("Hello", 26).is_err());
/// ```
pub fn encrypt_safe(text: &str, shift: i16) -> Result<String, CipherError> {
if text.is_empty() {
if text.trim().is_empty() {
return Err(CipherError::EmptyText);
}

Expand Down Expand Up @@ -185,7 +185,7 @@ pub fn encrypt_safe(text: &str, shift: i16) -> Result<String, CipherError> {
/// assert_eq!(result, "Hello");
/// ```
pub fn decrypt_safe(text: &str, shift: i16) -> Result<String, CipherError> {
if text.is_empty() {
if text.trim().is_empty() {
return Err(CipherError::EmptyText);
}

Expand Down
Loading