#How to pass string into another string when it is in {}
9 messages · Page 1 of 1 (latest)
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()
I thought about it, I also implemented it, but now compilers says that variable is void.
Does your if expression return a value?
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 😅