From 0c8e657ec07aff80389ac65fe7901ff25ce427d9 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 26 Dec 2019 02:58:20 +0100 Subject: [PATCH] Switch to Rust 2018 --- Cargo.toml | 1 + src/compressor.rs | 3 +-- src/database.rs | 4 ++-- src/main.rs | 15 +++------------ 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8295989..6bb8578 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ authors = ["Erik Johnston"] description = "A tool to compress some state in a Synapse instance's database" name = "synapse-compress-state" version = "0.1.0" +edition = "2018" [dependencies] clap = "2.32.0" diff --git a/src/compressor.rs b/src/compressor.rs index dfdf1e8..e8d85a5 100644 --- a/src/compressor.rs +++ b/src/compressor.rs @@ -33,8 +33,7 @@ use state_map::StateMap; use std::collections::BTreeMap; use string_cache::DefaultAtom as Atom; -use collapse_state_maps; -use StateGroupEntry; +use super::{collapse_state_maps, StateGroupEntry}; /// Holds information about a particular level. struct Level { diff --git a/src/database.rs b/src/database.rs index 94f5ca1..7cbfd95 100644 --- a/src/database.rs +++ b/src/database.rs @@ -18,7 +18,7 @@ use postgres::{Connection, TlsMode}; use rand::{distributions::Alphanumeric, thread_rng, Rng}; use std::{borrow::Cow, collections::BTreeMap, fmt}; -use StateGroupEntry; +use super::StateGroupEntry; /// Fetch the entries in state_groups_state (and their prev groups) for the /// given `room_id` by connecting to the postgres database at `db_url`. @@ -174,7 +174,7 @@ fn get_missing_from_db(conn: &Connection, missing_sgs: &[i64]) -> BTreeMap(pub &'a str); impl<'a> fmt::Display for PGEscapse<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut delim = Cow::from("$$"); while self.0.contains(&delim as &str) { let s: String = thread_rng().sample_iter(&Alphanumeric).take(10).collect(); diff --git a/src/main.rs b/src/main.rs index 0ce34c5..e2a5c3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,17 +16,6 @@ //! Synapse instance's database. Specifically, it aims to reduce the number of //! rows that a given room takes up in the `state_groups_state` table. -#[macro_use] -extern crate clap; -extern crate fallible_iterator; -extern crate indicatif; -extern crate jemallocator; -extern crate postgres; -extern crate rand; -extern crate rayon; -extern crate state_map; -extern crate string_cache; - mod compressor; mod database; @@ -36,7 +25,9 @@ static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; use compressor::Compressor; use database::PGEscapse; -use clap::{App, Arg}; +use clap::{ + crate_authors, crate_description, crate_name, crate_version, value_t_or_exit, App, Arg, +}; use indicatif::{ProgressBar, ProgressStyle}; use rayon::prelude::*; use state_map::StateMap;