Skip to content

Commit

Permalink
test: fix examples & add more edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
romancitodev committed Aug 28, 2024
1 parent 7377d1d commit 963946f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions examples/async.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use pistones::{lang::Response, Client, Error};
use pistones::{Client, Error};

#[tokio::main]
async fn main() -> Result<(), Error> {
let response = compile_code("rust", "fn main() { println!(\"Hola\") }").await?;
println("{response:?}");
Ok(())
}

async fn compile_code(lang: &str, code: &str) -> Result<Response, Error> {
let client = Client::new().await?.user_agent("@romancitodev")?;
client.run(lang, code).await

tokio::spawn(async move {
let _ = client
.run("rust", "fn main() { println!(\"Hola\") }")
.await
.unwrap();
});

println!("hello!");
Ok(())
}
2 changes: 1 addition & 1 deletion examples/refresh_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use pistones::{Client, Error};
#[tokio::main]
async fn main() -> Result<(), Error> {
// Normal client
let client = Client::new().await?;
let _ = Client::new().await?;
// Create client with cache disabled
let client = Client::new().await?.disable_cache();

Expand Down

0 comments on commit 963946f

Please sign in to comment.