Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied suggested clippy fixes, and formatted the code. #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use pastemyst::data::*;
#[tokio::main]
async fn main() -> DataResult<()> {
// Get language by name.
tokio::task::spawn_blocking(||call_get_language_by_name().unwrap());
tokio::task::spawn_blocking(|| call_get_language_by_name().unwrap());
call_get_language_by_name_async().await?;

// Get language by extension.
tokio::task::spawn_blocking(||call_get_language_by_extension().unwrap());
tokio::task::spawn_blocking(|| call_get_language_by_extension().unwrap());
call_get_language_by_extension_async().await?;
Ok(())
}
Expand Down
41 changes: 20 additions & 21 deletions examples/paste.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use pastemyst::str;
use pastemyst::paste::*;
use pastemyst::str;

type Error = Box<dyn std::error::Error>;
type Result<T, E = Error> = std::result::Result<T, E>;

#[tokio::main]
async fn main() -> Result<()> {
// Create pastes
tokio::task::spawn_blocking(||call_create_paste().unwrap());
tokio::task::spawn_blocking(|| call_create_paste().unwrap());
call_create_paste_async().await?;
// tokio::task::spawn_blocking(
// ||call_create_private_paste(
Expand All @@ -16,7 +16,7 @@ async fn main() -> Result<()> {
// "Your PasteMyst Token. Get it from: https://paste.myst.rs/user/settings").await?;

// Get pastes
tokio::task::spawn_blocking(||call_get_paste().unwrap());
tokio::task::spawn_blocking(|| call_get_paste().unwrap());
call_get_paste_async().await?;
// tokio::task::spawn_blocking(
// ||call_get_private_paste(
Expand All @@ -39,7 +39,9 @@ fn call_create_paste() -> Result<(), reqwest::Error> /*PasteResult<()>*/ {
_id: str!(""),
title: "Another pasty title".to_string(),
language: str!(pastemyst::data::language::CLANG),
code: String::from("#include \"stdio.h\"\n\nint main() {\n\tprintf(\"Hello World!\");\n}"),
code: String::from(
"#include <stdio.h>\n\nint main() {\n\tprintf(\"Hello World!\");\n}",
),
},
];
let data: CreateObject = CreateObject {
Expand Down Expand Up @@ -68,7 +70,9 @@ async fn call_create_paste_async() -> Result<()> {
_id: str!(""),
title: "Another pasty title".to_string(),
language: str!(pastemyst::data::language::CLANG),
code: String::from("#include \"stdio.h\"\n\nint main() {\n\tprintf(\"Hello World!\");\n}"),
code: String::from(
"#include <stdio.h>\n\nint main() {\n\tprintf(\"Hello World!\");\n}",
),
},
];
let data: CreateObject = CreateObject {
Expand Down Expand Up @@ -98,7 +102,9 @@ fn call_create_private_paste(auth_token: &str) -> PasteResult<()> {
_id: str!(""),
title: "Another pasty title".to_string(),
language: str!(pastemyst::data::language::CLANG),
code: String::from("#include \"stdio.h\"\n\nint main() {\n\tprintf(\"Hello World!\");\n}"),
code: String::from(
"#include \"stdio.h\"\n\nint main() {\n\tprintf(\"Hello World!\");\n}",
),
},
];
let data: CreateObject = CreateObject {
Expand All @@ -109,10 +115,7 @@ fn call_create_private_paste(auth_token: &str) -> PasteResult<()> {
tags: String::from(""),
pasties,
};
let paste = create_private_paste(
data,
auth_token,
)?;
let paste = create_private_paste(data, auth_token)?;
println!("https://paste.myst.rs/{}", paste._id);
Ok(())
}
Expand All @@ -131,7 +134,9 @@ async fn call_create_private_paste_async(auth_token: &str) -> PasteResult<()> {
_id: str!(""),
title: "Another pasty title".to_string(),
language: str!(pastemyst::data::language::CLANG),
code: String::from("#include \"stdio.h\"\n\nint main() {\n\tprintf(\"Hello World!\");\n}"),
code: String::from(
"#include \"stdio.h\"\n\nint main() {\n\tprintf(\"Hello World!\");\n}",
),
},
];
let data: CreateObject = CreateObject {
Expand All @@ -142,10 +147,7 @@ async fn call_create_private_paste_async(auth_token: &str) -> PasteResult<()> {
tags: String::from(""),
pasties,
};
let paste = create_private_paste(
data,
auth_token,
)?;
let paste = create_private_paste(data, auth_token)?;
println!("https://paste.myst.rs/{}", paste._id);
Ok(())
}
Expand Down Expand Up @@ -173,19 +175,16 @@ async fn call_get_paste_async() -> PasteResult<()> {
fn call_get_private_paste() -> PasteResult<()> {
let paste: PasteObject = get_private_paste(
"pasteID",
"Your PasteMyst Token. Get it from: https://paste.myst.rs/user/settings")?;
"Your PasteMyst Token. Get it from: https://paste.myst.rs/user/settings",
)?;
println!("{}", paste.ownerId);
Ok(())
}

/// Gets a private paste from pastemyst asynchronously.
#[allow(dead_code)]
async fn call_get_private_paste_async(auth_token: &str) -> PasteResult<()> {
let paste: PasteObject = get_private_paste_async(
"pasteID",
auth_token,
)
.await?;
let paste: PasteObject = get_private_paste_async("pasteID", auth_token).await?;
println!("{}", paste.isPrivate);
Ok(())
}
2 changes: 1 addition & 1 deletion examples/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pastemyst::time::*;

#[tokio::main]
async fn main() -> TimeResult<()> {
tokio::task::spawn_blocking(||call_expires_into_unix().unwrap());
tokio::task::spawn_blocking(|| call_expires_into_unix().unwrap());
call_expires_into_unix_async().await?;
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions examples/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use pastemyst::user::*;
#[tokio::main]
async fn main() -> UserResult<()> {
// Get a user.
tokio::task::spawn_blocking(||call_get_user().unwrap());
tokio::task::spawn_blocking(|| call_get_user().unwrap());
call_get_user_async().await?;

// Check if a user exists.
tokio::task::spawn_blocking(||call_user_exists().unwrap());
tokio::task::spawn_blocking(|| call_user_exists().unwrap());
call_user_exists_async().await?;
Ok(())
}
Expand Down
Loading