public/subjects/delete_prefix
davhojt bfe28c091b docs(delete_prefix) correct grammar 2022-06-13 00:46:37 +03:00
..
README.md docs(delete_prefix) correct grammar 2022-06-13 00:46:37 +03:00

README.md

delete_prefix

Instructions

Define the function delete_prefix which returns the string slice s with the prefix removed. It should be wrapped in Some. If prefix is not a prefix of s, then delete_prefix returns None.

Expected Function

pub fn delete_prefix(prefix: &str, s: &str) -> Option<&str> {
}

Usage

Here is a program to test your function.

use delete_prefix::delete_prefix;

fn main() {
	println!("{:?}", delete_prefix("ab", "abcdefghijklmnop"));
	println!("{:?}", delete_prefix("x", "abcdefghijklmnop"));
}

And its output:

$ cargo run
Some("cdefghijklmnop")
None
$