• 5 Posts
  • 138 Comments
Joined 1 year ago
cake
Cake day: November 24th, 2023

help-circle

  • It’s quite simple. Just remove the permalink field! If you are calculating it then no need to store it in the struct.

    If you do need the field to be there (ex you serialise it with serde), then create a method called new that takes everything but the permalink, construct your permalink there, then return a new object.

    Your permalink method can now just be self.permalink.to_string()

    P.S. in the second case I’d recommend to change the return type of self.permalink() to &str. It avoids unnecessary cloning of the string.


  • I wouldn’t mind having a explanation of what you want to do instead of the code. It’s not quite clear what you mean.

    Anyways, what you want is to transform an iterator (your Select) into an iterator of Option<String>?

    For that, there’s multiple ways but here’s the simplest:

    link_nodes.map(|node| node.value().attr("href").to_string())

    Essentially, for each elements, we execute a closure (arrow function in JavaScript) that transform the node into your href string.

    P.S. can’t guarantee it works, I don’t know what this “Select” type is, and I’m programming on mobile


  • I think they are referring to crates vs binaries vs cargo binaries.

    Crates are your libraries, not meant to be standalone, binaries are your .exe, cargo binaries are meant to be compiled by cargo on your machine and run through cargo, ex: cargo sqlx

    They might also refer test binaries and example binaries which are two executables that only compile the tesrs and the examples to make sure they work, but apart from that idk












  • I hate AI, but here it’s a bit understandable why copilot says that. If you ask the same thing to someone else they would surely respond 2 as they my imply you are trying to spell the word, and struggle on whether it’s one or two R on the last part.

    I know it’s a common thing to ask in french when we struggle to spell our overly complicated language, so it doesn’t shock me