Update to Rust 2018, work around a warning for diesel
This commit is contained in:
parent
3159bd8076
commit
8f130f95e6
@ -9,9 +9,10 @@ name = "ruma-identifiers"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/ruma/ruma-identifiers"
|
repository = "https://github.com/ruma/ruma-identifiers"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = "1.0"
|
lazy_static = "1.2"
|
||||||
rand = "0.5"
|
rand = "0.5"
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
41
src/lib.rs
41
src/lib.rs
@ -6,20 +6,6 @@
|
|||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
extern crate rand;
|
|
||||||
extern crate regex;
|
|
||||||
extern crate serde;
|
|
||||||
extern crate url;
|
|
||||||
|
|
||||||
#[cfg(feature = "diesel")]
|
|
||||||
#[macro_use]
|
|
||||||
extern crate diesel;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
extern crate serde_json;
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
convert::TryFrom,
|
convert::TryFrom,
|
||||||
error::Error as StdError,
|
error::Error as StdError,
|
||||||
@ -27,8 +13,9 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "diesel")]
|
#[cfg(feature = "diesel")]
|
||||||
use diesel::sql_types::Text;
|
use diesel::{FromSqlRow, sql_types::Text};
|
||||||
|
|
||||||
|
use lazy_static::lazy_static;
|
||||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::{
|
use serde::{
|
||||||
@ -201,7 +188,7 @@ struct RoomIdOrAliasIdVisitor;
|
|||||||
struct UserIdVisitor;
|
struct UserIdVisitor;
|
||||||
|
|
||||||
fn display(
|
fn display(
|
||||||
f: &mut Formatter,
|
f: &mut Formatter<'_>,
|
||||||
sigil: char,
|
sigil: char,
|
||||||
localpart: &str,
|
localpart: &str,
|
||||||
hostname: &Host,
|
hostname: &Host,
|
||||||
@ -261,7 +248,7 @@ fn parse_id<'a>(required_sigil: char, id: &'a str) -> Result<(&'a str, Host, u16
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||||
write!(f, "{}", self.description())
|
write!(f, "{}", self.description())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,25 +398,25 @@ impl From<ParseError> for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Display for EventId {
|
impl Display for EventId {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||||
display(f, '$', &self.opaque_id, &self.hostname, self.port)
|
display(f, '$', &self.opaque_id, &self.hostname, self.port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for RoomAliasId {
|
impl Display for RoomAliasId {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||||
display(f, '#', &self.alias, &self.hostname, self.port)
|
display(f, '#', &self.alias, &self.hostname, self.port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for RoomId {
|
impl Display for RoomId {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||||
display(f, '!', &self.opaque_id, &self.hostname, self.port)
|
display(f, '!', &self.opaque_id, &self.hostname, self.port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for RoomIdOrAliasId {
|
impl Display for RoomIdOrAliasId {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||||
match *self {
|
match *self {
|
||||||
RoomIdOrAliasId::RoomAliasId(ref room_alias_id) => display(
|
RoomIdOrAliasId::RoomAliasId(ref room_alias_id) => display(
|
||||||
f,
|
f,
|
||||||
@ -446,7 +433,7 @@ impl Display for RoomIdOrAliasId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Display for UserId {
|
impl Display for UserId {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||||
display(f, '@', &self.localpart, &self.hostname, self.port)
|
display(f, '@', &self.localpart, &self.hostname, self.port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -655,7 +642,7 @@ impl<'a> TryFrom<&'a str> for UserId {
|
|||||||
impl<'de> Visitor<'de> for EventIdVisitor {
|
impl<'de> Visitor<'de> for EventIdVisitor {
|
||||||
type Value = EventId;
|
type Value = EventId;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut Formatter) -> FmtResult {
|
fn expecting(&self, formatter: &mut Formatter<'_>) -> FmtResult {
|
||||||
write!(formatter, "a Matrix event ID as a string")
|
write!(formatter, "a Matrix event ID as a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,7 +660,7 @@ impl<'de> Visitor<'de> for EventIdVisitor {
|
|||||||
impl<'de> Visitor<'de> for RoomAliasIdVisitor {
|
impl<'de> Visitor<'de> for RoomAliasIdVisitor {
|
||||||
type Value = RoomAliasId;
|
type Value = RoomAliasId;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut Formatter) -> FmtResult {
|
fn expecting(&self, formatter: &mut Formatter<'_>) -> FmtResult {
|
||||||
write!(formatter, "a Matrix room alias ID as a string")
|
write!(formatter, "a Matrix room alias ID as a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +678,7 @@ impl<'de> Visitor<'de> for RoomAliasIdVisitor {
|
|||||||
impl<'de> Visitor<'de> for RoomIdVisitor {
|
impl<'de> Visitor<'de> for RoomIdVisitor {
|
||||||
type Value = RoomId;
|
type Value = RoomId;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut Formatter) -> FmtResult {
|
fn expecting(&self, formatter: &mut Formatter<'_>) -> FmtResult {
|
||||||
write!(formatter, "a Matrix room ID as a string")
|
write!(formatter, "a Matrix room ID as a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,7 +696,7 @@ impl<'de> Visitor<'de> for RoomIdVisitor {
|
|||||||
impl<'de> Visitor<'de> for RoomIdOrAliasIdVisitor {
|
impl<'de> Visitor<'de> for RoomIdOrAliasIdVisitor {
|
||||||
type Value = RoomIdOrAliasId;
|
type Value = RoomIdOrAliasId;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut Formatter) -> FmtResult {
|
fn expecting(&self, formatter: &mut Formatter<'_>) -> FmtResult {
|
||||||
write!(formatter, "a Matrix room ID or room alias ID as a string")
|
write!(formatter, "a Matrix room ID or room alias ID as a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,7 +714,7 @@ impl<'de> Visitor<'de> for RoomIdOrAliasIdVisitor {
|
|||||||
impl<'de> Visitor<'de> for UserIdVisitor {
|
impl<'de> Visitor<'de> for UserIdVisitor {
|
||||||
type Value = UserId;
|
type Value = UserId;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut Formatter) -> FmtResult {
|
fn expecting(&self, formatter: &mut Formatter<'_>) -> FmtResult {
|
||||||
write!(formatter, "a Matrix user ID as a string")
|
write!(formatter, "a Matrix user ID as a string")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user