Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
w4 committed Jul 23, 2020
1 parent 4eb9049 commit 2bbab69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,15 @@ pub fn generate_id() -> String {
pub async fn store_paste(id: String, content: String) {
purge_old().await;

ENTRIES
.write()
.await
.insert(id, content);
ENTRIES.write().await.insert(id, content);
}

/// Get a paste by id.
///
/// Returns `None` if the paste doesn't exist.
pub async fn get_paste(id: &str) -> Option<RwLockReadGuardRef<'_, LinkedHashMap<String, String>, String>> {
pub async fn get_paste(
id: &str,
) -> Option<RwLockReadGuardRef<'_, LinkedHashMap<String, String>, String>> {
// need to box the guard until owning_ref understands Pin is a stable address
let or = RwLockReadGuardRef::new(Box::new(ENTRIES.read().await));

Expand Down
9 changes: 6 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ async fn submit(input: Form<IndexForm>) -> Redirect {
#[put("/", data = "<input>")]
async fn submit_raw(input: Data, host: HostHeader<'_>) -> Result<String, Status> {
let mut data = String::new();
input.open().take(1024 * 1000)
.read_to_string(&mut data).await
input
.open()
.take(1024 * 1000)
.read_to_string(&mut data)
.await
.map_err(|_| Status::InternalServerError)?;

let id = generate_id();
Expand Down Expand Up @@ -108,7 +111,7 @@ async fn show_paste(key: String, plaintext: IsPlaintextRequest) -> Result<Conten
None => String::from(RawStr::from_str(entry).html_escape()),
};

// Add <code> tags to enable line numbering with CSS
// Add <code> tags to enable line numbering with CSS
let html = format!(
"<code>{}</code>",
code_highlighted.replace("\n", "\n</code><code>")
Expand Down

0 comments on commit 2bbab69

Please sign in to comment.