Trollface

codeberg: https://codeberg.org/asudox

aspe:keyoxide.org:D63IYCGSU4XXB5JSCBBHXXFEHQ

  • 1 Post
  • 34 Comments
Joined 7 months ago
cake
Cake day: April 28th, 2024

help-circle




  • Here’s what you are trying to do, with a one liner:

    fn get_links(mut link_nodes: Select) -> Vec<String> {
        link_nodes.retain(|node| node.value().attr("href").is_some()).into_iter().fold(Vec::new(), |links, node| links.push(link.value().attr("href").unwrap().to_string()))
    }
    

    edit: shorter and updated version:

    fn get_links(mut link_nodes: Select) -> Vec<String> {
        link_nodes.into_iter().filter_map(|node| node.value().attr("href").map(|href| href.to_string())).collect()
    }
    

    The retain method is to get rid of all the nodes which don’t have a href attribute and the fold method after it is to extract the href out of the nodes and push them into the vector.

    It might work or not, I’ve written this from my memory and I can’t exactly know what that Select is.

    I also hope you begin reading The Book without half assing it.





  • Normal distros

    • Pop!_OS
    • Mint
    • Fedora
    • Ubuntu

    Gaming distros

    • Garuda
    • Bazzite
    • Nobara

    …or any other distro really. I’ve been gaming on vanilla arch linux. It’s pretty stable and low maintenance once you’re done setting it up and don’t tinker much and have backups with something like Timeshift in place. archinstall script makes it really easy to install vanilla arch linux with everything essential configured.