0

The ideal result would be something like this:

lazy_static! {
    static ref LATESTGAMEDATA: god_rss::RSSGameData = async {
        println!("Loading latest game data...");
        god_rss::get_latest_game_data().await.unwrap()
    };
}

god_rss::RSSGameData (created by async god_rss::get_latest_game_data()) is a struct which contains three Vec<String>s

I cannot seem to find a way to apply this value, the ? operator won't work because it is not inside of a function...

steamsy
  • 104
  • 1
  • 8
  • 1
    I'd think the issue is [the async](https://github.com/rust-lang-nursery/lazy-static.rs/issues/167) rather than the `Ok`/`unwrap` or whatever. Use `async_once`, or see if you can call into the "current runtime" in order to resolve the lazy_static. – Masklinn Nov 12 '21 at 07:50
  • 2
    PS: actually posting the errors you get, and minimal reproduction case, is generally considered a good idea. If the reader has to assumes a thousand things, odds are some of the assumptions will be incorrect, and the more incorrect the assumptions the further off the answer will be. – Masklinn Nov 12 '21 at 07:51
  • You could try `static ref LATESTGAMEDATA: god_rss::RSSGameData = futures::executor::block_on(god_rss::get_latest_game_data()).unwrap()`. If you use tokio, you might use `tokio::runtime::Runtime::new().unwrap().block_on(...)` instead. – user4815162342 Nov 12 '21 at 15:28

0 Answers0