Derive Clone, Copy, PartialEq, Eq wherever possible

This commit is contained in:
Curtis McEnroe 2015-12-30 02:57:02 -05:00
parent 65eb87e1d4
commit 10775d0823
7 changed files with 12 additions and 11 deletions

View File

@ -21,7 +21,7 @@ pub trait FromResponse: Sized {
} }
/// Response parse errors. /// Response parse errors.
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ParseError { pub enum ParseError {
/// Expected response to be of type. /// Expected response to be of type.
ExpectedType(&'static str), ExpectedType(&'static str),
@ -56,7 +56,7 @@ impl Error for ParseError {
} }
/// JSON helper for response parsing. /// JSON helper for response parsing.
#[derive(Debug)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct JsonHelper<'a>(pub &'a Json); pub struct JsonHelper<'a>(pub &'a Json);
impl<'a> JsonHelper<'a> { impl<'a> JsonHelper<'a> {
@ -69,7 +69,7 @@ impl<'a> JsonHelper<'a> {
} }
/// JSON object helper for response parsing. /// JSON object helper for response parsing.
#[derive(Debug)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct JsonObjectHelper<'a>(pub &'a json::Object); pub struct JsonObjectHelper<'a>(pub &'a json::Object);
impl<'a> JsonObjectHelper<'a> { impl<'a> JsonObjectHelper<'a> {

View File

@ -10,7 +10,7 @@ use client::response::{FromResponse, ParseError, JsonHelper};
/// OAuth 2.0 error codes. /// OAuth 2.0 error codes.
/// ///
/// See [RFC 6749, section 5.2](http://tools.ietf.org/html/rfc6749#section-5.2). /// See [RFC 6749, section 5.2](http://tools.ietf.org/html/rfc6749#section-5.2).
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum OAuth2ErrorCode { pub enum OAuth2ErrorCode {
/// The request is missing a required parameter, includes an unsupported parameter value (other /// The request is missing a required parameter, includes an unsupported parameter value (other
/// than grant type), repeats a parameter, includes multiple credentials, utilizes more than /// than grant type), repeats a parameter, includes multiple credentials, utilizes more than
@ -57,7 +57,7 @@ impl<'a> From<&'a str> for OAuth2ErrorCode {
/// OAuth 2.0 error. /// OAuth 2.0 error.
/// ///
/// See [RFC 6749, section 5.2](http://tools.ietf.org/html/rfc6749#section-5.2). /// See [RFC 6749, section 5.2](http://tools.ietf.org/html/rfc6749#section-5.2).
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct OAuth2Error { pub struct OAuth2Error {
/// Error code. /// Error code.
pub code: OAuth2ErrorCode, pub code: OAuth2ErrorCode,

View File

@ -126,6 +126,7 @@
#![warn( #![warn(
missing_docs, missing_docs,
missing_debug_implementations, missing_debug_implementations,
missing_copy_implementations,
trivial_casts, trivial_casts,
trivial_numeric_casts, trivial_numeric_casts,
unused_extern_crates, unused_extern_crates,

View File

@ -25,7 +25,7 @@ pub trait Provider {
/// ///
/// See [Using OAuth 2.0 to Access Google /// See [Using OAuth 2.0 to Access Google
/// APIs](https://developers.google.com/identity/protocols/OAuth2). /// APIs](https://developers.google.com/identity/protocols/OAuth2).
#[derive(Debug)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Google; pub struct Google;
impl Provider for Google { impl Provider for Google {
type Lifetime = Expiring; type Lifetime = Expiring;
@ -37,7 +37,7 @@ impl Provider for Google {
/// GitHub OAuth 2.0 provider. /// GitHub OAuth 2.0 provider.
/// ///
/// See [OAuth, GitHub Developer Guide](https://developer.github.com/v3/oauth/). /// See [OAuth, GitHub Developer Guide](https://developer.github.com/v3/oauth/).
#[derive(Debug)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct GitHub; pub struct GitHub;
impl Provider for GitHub { impl Provider for GitHub {
type Lifetime = Static; type Lifetime = Static;
@ -49,7 +49,7 @@ impl Provider for GitHub {
/// Imgur OAuth 2.0 provider. /// Imgur OAuth 2.0 provider.
/// ///
/// See [OAuth 2.0, Imgur](https://api.imgur.com/oauth2). /// See [OAuth 2.0, Imgur](https://api.imgur.com/oauth2).
#[derive(Debug)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Imgur; pub struct Imgur;
impl Provider for Imgur { impl Provider for Imgur {
type Lifetime = Expiring; type Lifetime = Expiring;

View File

@ -7,7 +7,7 @@ use client::response::{FromResponse, ParseError, JsonHelper};
/// The bearer token type. /// The bearer token type.
/// ///
/// See [RFC 6750](http://tools.ietf.org/html/rfc6750). /// See [RFC 6750](http://tools.ietf.org/html/rfc6750).
#[derive(Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct Bearer<L: Lifetime> { pub struct Bearer<L: Lifetime> {
access_token: String, access_token: String,
scope: Option<String>, scope: Option<String>,

View File

@ -6,7 +6,7 @@ use super::Lifetime;
use client::response::{FromResponse, ParseError, JsonHelper}; use client::response::{FromResponse, ParseError, JsonHelper};
/// An expiring token. /// An expiring token.
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct Expiring { pub struct Expiring {
refresh_token: String, refresh_token: String,
expires: DateTime<UTC>, expires: DateTime<UTC>,

View File

@ -4,7 +4,7 @@ use super::Lifetime;
use client::response::{FromResponse, ParseError, JsonHelper}; use client::response::{FromResponse, ParseError, JsonHelper};
/// A static, non-expiring token. /// A static, non-expiring token.
#[derive(Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] #[derive(Debug, Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable)]
pub struct Static; pub struct Static;
impl Lifetime for Static { impl Lifetime for Static {