Skip to main content

prefix

Function prefix 

Source
pub fn prefix(text: &str, prefix: &str) -> String
Expand description

Prefix a multiline string with a specified prefix.

This function adds the specified prefix to the beginning of each line in the input text.

§Arguments

  • text - The multiline string to prefix
  • prefix - The prefix to add to each line

§Returns

  • String - The prefixed string

§Examples

use sal_text::prefix;

let text = "line 1\nline 2\nline 3";
let prefixed = prefix(text, "    ");
assert_eq!(prefixed, "    line 1\n    line 2\n    line 3");