Skip to content

Commit

Permalink
Cleaned up the docs in caesar.rs to match the same formatting and sty…
Browse files Browse the repository at this point in the history
…le as in the other modules.
  • Loading branch information
scriptandcompile committed Jun 9, 2024
1 parent 817f850 commit 125125c
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/ciphers/caesar.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
//! Caesar Cipher
//! Based on cipher_crypt::caesar
//!
//! # Algorithm
/// Encrypts a given [`&str`] using Caesar cipher.
///
/// Rotate each ascii character by shift.
/// Implements the Caesar Cipher based on cipher_crypt::caesar
///
/// Rotates each ascii character by shift.
/// The most basic example is ROT 13, which rotates 'a' to 'n'.
/// This implementation does not rotates unicode characters.
///
/// See [Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher) for more information.
///
/// # Arguments
///
/// `cipher` - String to transform.
///
/// `shift` - Amount to right-shift.
/// *`cipher` - A [`&str`] plain text to encrypt.
/// *`shift` - Amount to right-shift the text.
///
/// # Returns
///
/// An owned [`String`]
///
/// # Panic
///
/// This function won't panic
///
/// An owned [`String`] of the encrypted text.
///
/// # Examples
/// ```
///
/// ```rust
/// # use rust_algorithms::ciphers::caesar;
///
/// let encoded = caesar("one sheep two sheep", 3);
///
/// assert_eq!(encoded, "rqh vkhhs wzr vkhhs")
/// ```
pub fn caesar(cipher: &str, shift: u8) -> String {
Expand Down

0 comments on commit 125125c

Please sign in to comment.