Function basename_without_extension

Source
pub fn basename_without_extension(seq_url: &Url, extensions: &[&str]) -> String
Expand description

This function takes a sequence URL and a list of possible extensions, and returns the base name of the file without any of the provided extensions. It does this by first extracting the last segment of the URL path, and then iteratively removing any of the specified extensions from the end of the base name.

§Arguments

  • seq_url - A reference to a URL object representing the sequence file URL.
  • extensions - A slice of string slices representing the possible file extensions to be removed.

§Returns

  • A String containing the base name of the file without any of the specified extensions.

§Panics

This function will panic:

  1. If seq_url.path_segments() returns None, indicating that the URL does not have a path.
  2. If seq_url.path_segments().map(|c| c.collect::<Vec<_>>()).unwrap().last() returns None, indicating that the path does not have any segments.