#How to pass string into another string when it is in {}

9 messages · Page 1 of 1 (latest)

cosmic roost
#

How to pass string into another string when it is in {}

unreal vessel
#

I think you want this?

let imdb_link = if msg.content.starts_with(&"https://letterboxd.com/") {
  // stuff
  letteboxlink
};
#

Also your

.zip(0..101)
.next()
.unwrap()
.0.unwrap()
```is the same as
```rs
.next()
.unwrap()
.unwrap()
cosmic roost
#

I thought about it, I also implemented it, but now compilers says that variable is void.

unreal vessel
#

Does your if expression return a value?

cosmic roost
#
    let imdb_link = if 
    msg.content.starts_with(&"https://letterboxd.com/") {
        let response = reqwest::get(&msg.content).await?;
        let letterboxlink = if
         response.status().is_success() {
            let body = response.text().await?;
            let document = scraper::Html::parse_document(&body);
            let selector = scraper::Selector::parse(r#"a[data-track-action="IMDb"]"#).unwrap();
            document.select(&selector)
                .map(|x| x.value().attr("href"))
                .next()
                .unwrap()
                .unwrap()
            } else {
             &msg.content
            };
        letterboxlink
    } else {
        &msg.content
    };
#

I made a mistake. i had ; at the end of letterboxlink

#

but now it compilers returns me this

error: `document` does not live long enough
label: borrow later stored here
#

I figured it out 😅