fn string_to_vec(input: &str) -> Option<Vec<String>> {
    let mut vec = Vec::new();

    // Iterator over all lines from input
    let mut iter = input.lines();

    // Get first line
    let mut first = match iter.next() {
        Some(first) => first.to_string(),
        None => return None,
    };

    // Try to get second line (if it's a multiline input)
    match iter.next() {
        Some(second) => {
            // If input is multiline, add a unix newline for first line
            first.push('\n');
            vec.push(first);

            // Do the same for the second line (otherwise it will be lost)
            let mut second = second.to_string();
            second.push('\n');
            vec.push(second);
        }
        // If there is no second line return first line without newline
        None => vec.push(first),
    }

    // Iterate over the rest of the multiline input
    for line in iter {
        // Add unix newline character at the end of each line
        let mut line = line.to_string();
        line.push('\n');

        vec.push(line);
    }

    Some(vec)
}
/// Convert a one-line password to a vector
Convert a one-line password to a vector
Convert a one - line password to a vector
fn string_to_vec(input: &str) -> Option<Vec<String>> {
    let mut vec = Vec::new();
    // Iterator over all lines from input
    let mut iter = input.lines();
    // Get first line
    let mut first = match iter.next() {
        Some(first) => first.to_string(),
        None => return None,
    };
    // Try to get second line (if it's a multiline input)
    match iter.next() {
        Some(second) => {
            // If input is multiline, add a unix newline for first line
            first.push('\n');
            vec.push(first);
            // Do the same for the second line (otherwise it will be lost)
            let mut second = second.to_string();
            second.push('\n');
            vec.push(second);
        }
        // If there is no second line return first line without newline
        None => vec.push(first),
    }
    // Iterate over the rest of the multiline input
    for line in iter {
        // Add unix newline character at the end of each line
        let mut line = line.to_string();
        line.push('\n');
        vec.push(line);
    }
    Some(vec)
}
fn string_to_vec ( input : & str ) -> Option < Vec < String > > { let mut vec = Vec :: new ( ) ; // Iterator over all lines from input let mut iter = input . lines ( ) ; // Get first line let mut first = match iter . next ( ) { Some ( first ) => first . to_string ( ) , None => return None , } ; // Try to get second line (if it's a multiline input) match iter . next ( ) { Some ( second ) => { // If input is multiline, add a unix newline for first line first . push ( '\n' ) ; vec . push ( first ) ; // Do the same for the second line (otherwise it will be lost) let mut second = second . to_string ( ) ; second . push ( '\n' ) ; vec . push ( second ) ; } // If there is no second line return first line without newline None => vec . push ( first ) , } // Iterate over the rest of the multiline input for line in iter { // Add unix newline character at the end of each line let mut line = line . to_string ( ) ; line . push ( '\n' ) ; vec . push ( line ) ; } Some ( vec ) }
Convert a one-line password to a vector
Convert a one - line password to a vector
input
&str
input
&str