Skip to main content

extract_keywords

Function extract_keywords 

Source
pub fn extract_keywords(metadata: &HashMap<String, String>) -> Vec<String>
Expand description

Extracts keywords from the metadata.

This function looks for a “keywords” key in the metadata and splits its value into a vector of strings.

§Arguments

  • metadata - A reference to a HashMap containing the metadata.

§Returns

A vector of strings representing the keywords. Returns an empty vector if no keywords are found.

§Example

use std::collections::HashMap;
use metadata_gen::extract_keywords;

let mut metadata = HashMap::new();
metadata.insert("keywords".to_string(), "rust, metadata, parsing".to_string());

let keywords = extract_keywords(&metadata);
assert_eq!(keywords, vec!["rust", "metadata", "parsing"]);