Function chop

Source
pub fn chop(input: &str) -> String
Expand description

Removes the last character from a string. If the string ends in “\r\n”, then removes both characters.

§Arguments

  • input - A string slice that holds the string to be processed.

§Returns

A String with the last character removed, or both characters if it ends with “\r\n”.

§Examples

use rust_string_utils::utils::chomp_chop::chop;
let result = chop("Hello, world!\r\n");
assert_eq!(result, "Hello, world!");
use rust_string_utils::utils::chomp_chop::chop;
let result = chop("Hello, world!");
assert_eq!(result, "Hello, world");