使用egg_模式板条箱在用户twitter推文时间线上迭代
我正在使用rust egg_模式板条箱来迭代用户的tweet时间线,并查找他们是否发布了一条comp所需的tweet。现在我已经基本上完成了所有的工作,但是我无法确定如何在循环中处理这些代码 我可能没有正确使用egg_模式api,但我不确定使用egg_模式板条箱在用户twitter推文时间线上迭代,twitter,rust,Twitter,Rust,我正在使用rust egg_模式板条箱来迭代用户的tweet时间线,并查找他们是否发布了一条comp所需的tweet。现在我已经基本上完成了所有的工作,但是我无法确定如何在循环中处理这些代码 我可能没有正确使用egg_模式api,但我不确定 let (timeline, feed) = timeline.start().await?; loop { for tweet in feed.iter() { let (tfound, mfound
let (timeline, feed) = timeline.start().await?;
loop {
for tweet in feed.iter() {
let (tfound, mfound) = check_tweet(tweet).await?;
tweets_checked += 1;
// Return if both are found.
if tweet_found && media_found {
let id = tweet.id as i64;
return Ok((tweet_found, media_found, id, tweets_checked));
}
}
let (timeline, feed) = &timeline.older(None).await?;
}
这给了我以下错误:
error[E0382]: use of moved value: `timeline`
--> src/check_twitter/main.rs:145:33
|
125 | let (timeline, feed) = timeline.start().await?;
| -------- move occurs because `timeline` has type `egg_mode::tweet::Timeline`, which does not implement the `Copy` trait
...
145 | let (timeline, feed) = &timeline.older(None).await?;
| ^^^^^^^^ ----------- `timeline` moved due to this method call, in previous iteration of loop
|
note: this function takes ownership of the receiver `self`, which moves `timeline`
--> /home/utx0/.cargo/git/checkouts/egg-mode-01a8f29f644cee57/6b81073/src/tweet/mod.rs:520:18
|
520 | pub fn older(self, since_id: Option<u64>) -> TimelineFuture {
| ^^^^
错误[E0382]:使用移动值:`timeline`
-->src/check_twitter/main.rs:145:33
|
125 | let(timeline,feed)=timeline.start().wait?;
|-----之所以发生移动,是因为'timeline'的类型为'egg_mode::tweet::timeline',而该类型未实现'Copy'特性
...
145 | let(timeline,feed)=&timeline.older(None)。等待?;
|^^^^^^---------`timeline`在循环的上一次迭代中由于此方法调用而移动
|
注意:此函数获取接收者“self”的所有权,该接收者移动“timeline”`
-->/home/utx0/.cargo/git/checkout/egg-mode-01a8f29f644cee57/6b81073/src/tweet/mod.rs:520:18
|
520 | pub fn older(self,自_id:Option)->TimelineFuture{
| ^^^^
我修复了它。工作解决方案是:
let (mut timeline, mut feed) = timeline.start().await?;
loop {
let mut id: u64 = 0;
for tweet in feed.iter() {
let (tfound, mfound) = check_tweet(tweet).await?;
tweets_checked += 1;
id = tweet.id;
if tfound == true {
tweet_found = tfound;
tweet_id = tweet.id as i64;
}
if mfound == true {
media_found = mfound;
}
// Return if both are found.
if tweet_found && media_found {
let id = tweet.id as i64;
return Ok((tweet_found, media_found, id, tweets_checked));
}
}
let (ntimeline, nfeed) = timeline.older(Some(id)).await?;
timeline = ntimeline;
feed = nfeed;
}