summaryrefslogtreecommitdiffstats
path: root/vendor/overload
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/overload')
-rw-r--r--vendor/overload/.cargo-checksum.json1
-rw-r--r--vendor/overload/Cargo.toml22
-rw-r--r--vendor/overload/LICENSE21
-rw-r--r--vendor/overload/README.md64
-rw-r--r--vendor/overload/logo.pngbin0 -> 19188 bytes
-rw-r--r--vendor/overload/src/assignment.rs27
-rw-r--r--vendor/overload/src/binary.rs28
-rw-r--r--vendor/overload/src/lib.rs257
-rw-r--r--vendor/overload/src/unary.rs20
-rw-r--r--vendor/overload/tests/assignment.rs89
-rw-r--r--vendor/overload/tests/binary.rs72
-rw-r--r--vendor/overload/tests/unary.rs21
12 files changed, 622 insertions, 0 deletions
diff --git a/vendor/overload/.cargo-checksum.json b/vendor/overload/.cargo-checksum.json
new file mode 100644
index 000000000..dfd877e5b
--- /dev/null
+++ b/vendor/overload/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.toml":"7dae2c1f39fcd51345ecd0c84ff5ffd2544087b2fce175d253d388c4e61af61c","LICENSE":"0d1bdcc9f95914fc1709781e65a75b85db7f73fd1c335bf6f7b1aae618df322e","README.md":"163212683c01ec376c6fc1d4b6acb10cc1cb4af622e9ddbd869a48c7ac9c6169","logo.png":"6992807474a15bf663aeeb357b6038cdbaed7f5787a26941d1fc006176c3a6ae","src/assignment.rs":"f4ff0b288ed0d7cd03bd53d3c5f452ffdd36e20d816f6f68762ace1c2609a445","src/binary.rs":"321c474d28d7b8367ba71ad6b8691d023cefce4d2b9417c454e57ada42b618c6","src/lib.rs":"542d5b297d3b9039450dce66e58b89b8d3707ee322230f7e9cc25f367e6338a1","src/unary.rs":"f2f87399a153e225acc4899651ad079bf02b4fe426fb5c94799eb2747b84a870","tests/assignment.rs":"635f4a214ad9e725d2f46d12983a96167ac7bd8af979e69d20bdcd8739d9e3a9","tests/binary.rs":"1acc26022414a6d54f7fe18d85c41433dec2b6adb6615d04a261f9b47c438b88","tests/unary.rs":"4bc733e466c19296bc3738f866b710fc421a04f6dd0180348bd2fddecdc88c51"},"package":"b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"} \ No newline at end of file
diff --git a/vendor/overload/Cargo.toml b/vendor/overload/Cargo.toml
new file mode 100644
index 000000000..1e0fbc514
--- /dev/null
+++ b/vendor/overload/Cargo.toml
@@ -0,0 +1,22 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+edition = "2018"
+name = "overload"
+version = "0.1.1"
+authors = ["Daniel Salvadori <danaugrs@gmail.com>"]
+description = "Provides a macro to simplify operator overloading."
+keywords = ["operator", "overloading", "macro", "op"]
+categories = ["rust-patterns"]
+license = "MIT"
+repository = "https://github.com/danaugrs/overload"
diff --git a/vendor/overload/LICENSE b/vendor/overload/LICENSE
new file mode 100644
index 000000000..0ed504b3c
--- /dev/null
+++ b/vendor/overload/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Daniel Augusto Rizzi Salvadori
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE. \ No newline at end of file
diff --git a/vendor/overload/README.md b/vendor/overload/README.md
new file mode 100644
index 000000000..c40088ead
--- /dev/null
+++ b/vendor/overload/README.md
@@ -0,0 +1,64 @@
+<p align="center"><img width="460" src="https://github.com/danaugrs/overload/blob/master/logo.png"></p>
+<p align="center">
+ <a href="https://docs.rs/overload"><img src="https://docs.rs/overload/badge.svg"/></a>
+ <a href="https://crates.io/crates/overload"><img src="https://img.shields.io/crates/v/overload.svg"/></a>
+</p>
+
+Provides a macro to simplify operator overloading. See the [documentation](https://docs.rs/overload/) for details and supported operators.
+
+## Example
+
+```rust
+extern crate overload;
+use overload::overload;
+use std::ops; // <- don't forget this or you'll get nasty errors
+
+#[derive(PartialEq, Debug)]
+struct Val {
+ v: i32
+}
+
+overload!((a: ?Val) + (b: ?Val) -> Val { Val { v: a.v + b.v } });
+```
+
+The macro call in the snippet above generates the following code:
+
+```rust
+impl ops::Add<Val> for Val {
+ type Output = Val;
+ fn add(self, b: Val) -> Self::Output {
+ let a = self;
+ Val { v: a.v + b.v }
+ }
+}
+impl ops::Add<&Val> for Val {
+ type Output = Val;
+ fn add(self, b: &Val) -> Self::Output {
+ let a = self;
+ Val { v: a.v + b.v }
+ }
+}
+impl ops::Add<Val> for &Val {
+ type Output = Val;
+ fn add(self, b: Val) -> Self::Output {
+ let a = self;
+ Val { v: a.v + b.v }
+ }
+}
+impl ops::Add<&Val> for &Val {
+ type Output = Val;
+ fn add(self, b: &Val) -> Self::Output {
+ let a = self;
+ Val { v: a.v + b.v }
+ }
+}
+```
+
+We are now able to add `Val`s and `&Val`s in any combination:
+
+```rust
+assert_eq!(Val{v:3} + Val{v:5}, Val{v:8});
+assert_eq!(Val{v:3} + &Val{v:5}, Val{v:8});
+assert_eq!(&Val{v:3} + Val{v:5}, Val{v:8});
+assert_eq!(&Val{v:3} + &Val{v:5}, Val{v:8});
+```
diff --git a/vendor/overload/logo.png b/vendor/overload/logo.png
new file mode 100644
index 000000000..61d33090b
--- /dev/null
+++ b/vendor/overload/logo.png
Binary files differ
diff --git a/vendor/overload/src/assignment.rs b/vendor/overload/src/assignment.rs
new file mode 100644
index 000000000..550f07a96
--- /dev/null
+++ b/vendor/overload/src/assignment.rs
@@ -0,0 +1,27 @@
+#[doc(hidden)]
+#[macro_export(local_inner_macros)]
+macro_rules! _overload_assignment {
+ (+=, $($t:tt)+) => (_overload_assignment_internal!(AddAssign, add_assign, $($t)+););
+ (-=, $($t:tt)+) => (_overload_assignment_internal!(SubAssign, sub_assign, $($t)+););
+ (*=, $($t:tt)+) => (_overload_assignment_internal!(MulAssign, mul_assign, $($t)+););
+ (/=, $($t:tt)+) => (_overload_assignment_internal!(DivAssign, div_assign, $($t)+););
+ (%=, $($t:tt)+) => (_overload_assignment_internal!(RemAssign, rem_assign, $($t)+););
+ (&=, $($t:tt)+) => (_overload_assignment_internal!(BitAndAssign, bitand_assign, $($t)+););
+ (|=, $($t:tt)+) => (_overload_assignment_internal!(BitOrAssign, bitor_assign, $($t)+););
+ (^=, $($t:tt)+) => (_overload_assignment_internal!(BitXorAssign, bitxor_assign, $($t)+););
+ (<<=, $($t:tt)+) => (_overload_assignment_internal!(ShlAssign, shl_assign, $($t)+););
+ (>>=, $($t:tt)+) => (_overload_assignment_internal!(ShrAssign, shr_assign, $($t)+););
+}
+
+#[doc(hidden)]
+#[macro_export(local_inner_macros)]
+macro_rules! _overload_assignment_internal {
+ ($op_trait:ident, $op_fn:ident, $li:ident, $lt:ty, $ri:ident, $rt:ty, $body:block) => (
+ impl ops::$op_trait<$rt> for $lt {
+ fn $op_fn(&mut self, $ri: $rt) {
+ let $li = self;
+ $body
+ }
+ }
+ );
+}
diff --git a/vendor/overload/src/binary.rs b/vendor/overload/src/binary.rs
new file mode 100644
index 000000000..b4c781bff
--- /dev/null
+++ b/vendor/overload/src/binary.rs
@@ -0,0 +1,28 @@
+#[doc(hidden)]
+#[macro_export(local_inner_macros)]
+macro_rules! _overload_binary {
+ (+, $($t:tt)+) => (_overload_binary_internal!(Add, add, $($t)+););
+ (-, $($t:tt)+) => (_overload_binary_internal!(Sub, sub, $($t)+););
+ (*, $($t:tt)+) => (_overload_binary_internal!(Mul, mul, $($t)+););
+ (/, $($t:tt)+) => (_overload_binary_internal!(Div, div, $($t)+););
+ (%, $($t:tt)+) => (_overload_binary_internal!(Rem, rem, $($t)+););
+ (&, $($t:tt)+) => (_overload_binary_internal!(BitAnd, bitand, $($t)+););
+ (|, $($t:tt)+) => (_overload_binary_internal!(BitOr, bitor, $($t)+););
+ (^, $($t:tt)+) => (_overload_binary_internal!(BitXor, bitxor, $($t)+););
+ (<<, $($t:tt)+) => (_overload_binary_internal!(Shl, shl, $($t)+););
+ (>>, $($t:tt)+) => (_overload_binary_internal!(Shr, shr, $($t)+););
+}
+
+#[doc(hidden)]
+#[macro_export(local_inner_macros)]
+macro_rules! _overload_binary_internal {
+ ($op_trait:ident, $op_fn:ident, $li:ident, $lt:ty, $ri:ident, $rt:ty, $out:ty, $body:block) => (
+ impl ops::$op_trait<$rt> for $lt {
+ type Output = $out;
+ fn $op_fn(self, $ri: $rt) -> Self::Output {
+ let $li = self;
+ $body
+ }
+ }
+ );
+}
diff --git a/vendor/overload/src/lib.rs b/vendor/overload/src/lib.rs
new file mode 100644
index 000000000..9364d7a38
--- /dev/null
+++ b/vendor/overload/src/lib.rs
@@ -0,0 +1,257 @@
+//! Provides a macro to simplify operator overloading.
+//!
+//! To use, include the following:
+//! ```
+//! extern crate overload;
+//! use overload::overload;
+//! use std::ops; // <- don't forget this or you'll get nasty errors
+//! ```
+//!
+//! # Introduction
+//!
+//! Suppose we have the following `struct` definition:
+//! ```
+//! #[derive(PartialEq, Debug)]
+//! struct Val {
+//! v: i32
+//! }
+//! ```
+//! We can overload the addition of `Val`s like so:
+//! ```
+//! # extern crate overload;
+//! # use overload::overload;
+//! # use std::ops;
+//! # #[derive(PartialEq, Debug)]
+//! # struct Val {
+//! # v: i32
+//! # }
+//! overload!((a: Val) + (b: Val) -> Val { Val { v: a.v + b.v } });
+//! ```
+//! The macro call above generates the following code:
+//! ```ignore
+//! impl ops::Add<Val> for Val {
+//! type Output = Val;
+//! fn add(self, b: Val) -> Self::Output {
+//! let a = self;
+//! Val { v: a.v + b.v }
+//! }
+//! }
+//! ```
+//! We are now able to add `Val`s:
+//! ```
+//! # extern crate overload;
+//! # use overload::overload;
+//! # use std::ops;
+//! # #[derive(PartialEq, Debug)]
+//! # struct Val {
+//! # v: i32
+//! # }
+//! # overload!((a: Val) + (b: Val) -> Val { Val { v: a.v + b.v } });
+//! assert_eq!(Val{v:3} + Val{v:5}, Val{v:8});
+//! ```
+//!
+//! # Owned and borrowed types
+//!
+//! If we also wanted to overload addition for the borrowed type `&Val` we could write:
+//! ```
+//! # extern crate overload;
+//! # use overload::overload;
+//! # use std::ops;
+//! # #[derive(PartialEq, Debug)]
+//! # struct Val {
+//! # v: i32
+//! # }
+//! overload!((a: &Val) + (b: &Val) -> Val { Val { v: a.v + b.v } });
+//! ```
+//! We might also want to overload addition between the owned and borrowed types:
+//! ```
+//! # extern crate overload;
+//! # use overload::overload;
+//! # use std::ops;
+//! # #[derive(PartialEq, Debug)]
+//! # struct Val {
+//! # v: i32
+//! # }
+//! overload!((a: Val) + (b: &Val) -> Val { Val { v: a.v + b.v } });
+//! overload!((a: &Val) + (b: Val) -> Val { Val { v: a.v + b.v } });
+//! ```
+//! Let's see how we can write these combinations more concisely.
+//!
+//! We can include a `?` in front of a type to indicate that it should stand in for both the owned and borrowed type.
+//!
+//! To overload addition for all four combinations between `Val` and `&Val` we can therefore simply include a `?` in front of both types:
+//! ```
+//! # extern crate overload;
+//! # use overload::overload;
+//! # use std::ops;
+//! # #[derive(PartialEq, Debug)]
+//! # struct Val {
+//! # v: i32
+//! # }
+//! overload!((a: ?Val) + (b: ?Val) -> Val { Val { v: a.v + b.v } });
+//! ```
+//! The macro call above generates the following code:
+//! ```ignore
+//! impl ops::Add<Val> for Val {
+//! type Output = Val;
+//! fn add(self, b: Val) -> Self::Output {
+//! let a = self;
+//! Val { v: a.v + b.v }
+//! }
+//! }
+//!
+//! impl ops::Add<&Val> for Val {
+//! type Output = Val;
+//! fn add(self, b: &Val) -> Self::Output {
+//! let a = self;
+//! Val { v: a.v + b.v }
+//! }
+//! }
+//!
+//! impl ops::Add<Val> for &Val {
+//! type Output = Val;
+//! fn add(self, b: Val) -> Self::Output {
+//! let a = self;
+//! Val { v: a.v + b.v }
+//! }
+//! }
+//!
+//! impl ops::Add<&Val> for &Val {
+//! type Output = Val;
+//! fn add(self, b: &Val) -> Self::Output {
+//! let a = self;
+//! Val { v: a.v + b.v }
+//! }
+//! }
+//! ```
+//! We are now able to add `Val`s and `&Val`s in any combination:
+//! ```
+//! # extern crate overload;
+//! # use overload::overload;
+//! # use std::ops;
+//! # #[derive(PartialEq, Debug)]
+//! # struct Val {
+//! # v: i32
+//! # }
+//! # overload!((a: ?Val) + (b: ?Val) -> Val { Val { v: a.v + b.v } });
+//! assert_eq!(Val{v:3} + Val{v:5}, Val{v:8});
+//! assert_eq!(Val{v:3} + &Val{v:5}, Val{v:8});
+//! assert_eq!(&Val{v:3} + Val{v:5}, Val{v:8});
+//! assert_eq!(&Val{v:3} + &Val{v:5}, Val{v:8});
+//! ```
+//!
+//! # Binary operators
+//!
+//! The general syntax to overload a binary operator between types `<a_type>` and `<b_type>` is:
+//! ```ignore
+//! overload!((<a_ident>: <a_type>) <op> (<b_ident>: <b_type>) -> <out_type> { /*body*/ });
+//! ```
+//! Inside the body you can use `<a_ident>` and `<b_ident>` freely to perform any computation.
+//!
+//! The last line of the body needs to be an expression (i.e. no `;` at the end of the line) of type `<out_type>`.
+//!
+//! | Operator | Example | Trait |
+//! |----------|-----------------------------------------------------------------|--------|
+//! | + | `overload!((a: A) + (b: B) -> C { /*...*/ );` | Add |
+//! | - | `overload!((a: A) - (b: B) -> C { /*...*/ );` | Sub |
+//! | * | `overload!((a: A) * (b: B) -> C { /*...*/ );` | Mul |
+//! | / | `overload!((a: A) / (b: B) -> C { /*...*/ );` | Div |
+//! | % | `overload!((a: A) % (b: B) -> C { /*...*/ );` | Rem |
+//! | & | `overload!((a: A) & (b: B) -> C { /*...*/ );` | BitAnd |
+//! | \| | <code>overload!((a: A) &vert; (b: B) -> C { /\*...*\/ );</code> | BitOr |
+//! | ^ | `overload!((a: A) ^ (b: B) -> C { /*...*/ );` | BitXor |
+//! | << | `overload!((a: A) << (b: B) -> C { /*...*/ );` | Shl |
+//! | >> | `overload!((a: A) >> (b: B) -> C { /*...*/ );` | Shr |
+//!
+//! # Assignment operators
+//!
+//! The general syntax to overload an assignment operator between types `<a_type>` and `<b_type>` is:
+//! ```ignore
+//! overload!((<a_ident>: &mut <a_type>) <op> (<b_ident>: <b_type>) { /*body*/ });
+//! ```
+//! Inside the body you can use `<a_ident>` and `<b_ident>` freely to perform any computation and mutate `<a_ident>` as desired.
+//!
+//! | Operator | Example | Trait |
+//! |----------|------------------------------------------------------------------|--------------|
+//! | += | `overload!((a: &mut A) += (b: B) { /*...*/ );` | AddAssign |
+//! | -= | `overload!((a: &mut A) -= (b: B) { /*...*/ );` | SubAssign |
+//! | *= | `overload!((a: &mut A) *= (b: B) { /*...*/ );` | MulAssign |
+//! | /= | `overload!((a: &mut A) /= (b: B) { /*...*/ );` | DivAssign |
+//! | %= | `overload!((a: &mut A) %= (b: B) { /*...*/ );` | RemAssign |
+//! | &= | `overload!((a: &mut A) &= (b: B) { /*...*/ );` | BitAndAssign |
+//! | \|= | <code>overload!((a: &mut A) &vert;= (b: B) { /\*...*\/ );</code> | BitOrAssign |
+//! | ^= | `overload!((a: &mut A) ^= (b: B) { /*...*/ );` | BitXorAssign |
+//! | <<= | `overload!((a: &mut A) <<= (b: B) { /*...*/ );` | ShlAssign |
+//! | >>= | `overload!((a: &mut A) >>= (b: B) { /*...*/ );` | ShrAssign |
+//!
+//! # Unary operators
+//!
+//! The general syntax to overload a unary operator for type `<a_type>` is:
+//! ```ignore
+//! overload!(<op> (<a_ident>: <a_type>) -> <out_type> { /*body*/ });
+//! ```
+//! Inside the body you can use `<a_ident>` freely to perform any computation.
+//!
+//! The last line of the body needs to be an expression (i.e. no `;` at the end of the line) of type `<out_type>`.
+//!
+//! | Operator | Example | Trait |
+//! |----------|---------------------------------------------------------|-------|
+//! | - | `overload!(- (a: A) -> B { /*...*/ );` | Neg |
+//! | ! | `overload!(! (a: A) -> B { /*...*/ );` | Not |
+//!
+//! # Notes
+//!
+//! Remember that you can only overload operators between one or more types if at least one of the types is defined in the current crate.
+
+#[macro_use]
+mod unary;
+
+#[macro_use]
+mod assignment;
+
+#[macro_use]
+mod binary;
+
+/// Overloads an operator. See the [module level documentation](index.html) for more information.
+#[macro_export(local_inner_macros)]
+macro_rules! overload {
+ // Unary (both owned and borrowed)
+ ($op:tt ($i:ident : ? $t:ty) -> $out:ty $body:block) => (
+ _overload_unary!($op, $i, $t, $out, $body);
+ _overload_unary!($op, $i, &$t, $out, $body);
+ );
+ // Unary (either owned or borrowed)
+ ($op:tt ($i:ident : $t:ty) -> $out:ty $body:block) => (
+ _overload_unary!($op, $i, $t, $out, $body);
+ );
+ // Assignment (both owned and borrowed)
+ (($li:ident : &mut $lt:ty) $op:tt ($ri:ident : ? $rt:ty) $body:block) => (
+ _overload_assignment!($op, $li, $lt, $ri, $rt, $body);
+ _overload_assignment!($op, $li, $lt, $ri, &$rt, $body);
+ );
+ // Assignment (either owned or borrowed)
+ (($li:ident : &mut $lt:ty) $op:tt ($ri:ident : $rt:ty) $body:block) => (
+ _overload_assignment!($op, $li, $lt, $ri, $rt, $body);
+ );
+ // Binary (both - both)
+ (($li:ident : ? $lt:ty) $op:tt ($ri:ident : ? $rt:ty) -> $out:ty $body:block) => (
+ _overload_binary!($op, $li, $lt, $ri, $rt, $out, $body);
+ _overload_binary!($op, $li, $lt, $ri, &$rt, $out, $body);
+ _overload_binary!($op, $li, &$lt, $ri, $rt, $out, $body);
+ _overload_binary!($op, $li, &$lt, $ri, &$rt, $out, $body);
+ );
+ // Binary (both - either)
+ (($li:ident : ? $lt:ty) $op:tt ($ri:ident : $rt:ty) -> $out:ty $body:block) => (
+ _overload_binary!($op, $li, $lt, $ri, $rt, $out, $body);
+ _overload_binary!($op, $li, &$lt, $ri, $rt, $out, $body);
+ );
+ // Binary (either - both)
+ (($li:ident : $lt:ty) $op:tt ($ri:ident : ? $rt:ty) -> $out:ty $body:block) => (
+ _overload_binary!($op, $li, $lt, $ri, $rt, $out, $body);
+ _overload_binary!($op, $li, $lt, $ri, &$rt, $out, $body);
+ );
+ // Binary (either - either)
+ (($li:ident : $lt:ty) $op:tt ($ri:ident : $rt:ty) -> $out:ty $body:block) => (
+ _overload_binary!($op, $li, $lt, $ri, $rt, $out, $body);
+ );
+}
diff --git a/vendor/overload/src/unary.rs b/vendor/overload/src/unary.rs
new file mode 100644
index 000000000..da8f6b590
--- /dev/null
+++ b/vendor/overload/src/unary.rs
@@ -0,0 +1,20 @@
+#[doc(hidden)]
+#[macro_export(local_inner_macros)]
+macro_rules! _overload_unary {
+ (-, $($t:tt)+) => (_overload_unary_internal!(Neg, neg, $($t)+););
+ (!, $($t:tt)+) => (_overload_unary_internal!(Not, not, $($t)+););
+}
+
+#[doc(hidden)]
+#[macro_export(local_inner_macros)]
+macro_rules! _overload_unary_internal {
+ ($op_trait:ident, $op_fn:ident, $i:ident, $t:ty, $out:ty, $body:block) => (
+ impl ops::$op_trait for $t {
+ type Output = $out;
+ fn $op_fn(self) -> Self::Output {
+ let $i = self;
+ $body
+ }
+ }
+ );
+}
diff --git a/vendor/overload/tests/assignment.rs b/vendor/overload/tests/assignment.rs
new file mode 100644
index 000000000..9657b4bd4
--- /dev/null
+++ b/vendor/overload/tests/assignment.rs
@@ -0,0 +1,89 @@
+extern crate overload;
+use overload::overload;
+use std::ops;
+
+#[derive(PartialEq, Debug)]
+struct A(i32);
+
+#[derive(PartialEq, Debug)]
+struct B(i32);
+
+overload!((a: &mut A) += (b: B) { a.0 += b.0; });
+#[test]
+fn add_assign() {
+ let mut a = A(3);
+ a += B(4);
+ assert_eq!(A(3 + 4), a);
+}
+
+overload!((a: &mut A) -= (b: B) { a.0 -= b.0; });
+#[test]
+fn sub_assign() {
+ let mut a = A(3);
+ a -= B(4);
+ assert_eq!(A(3 - 4), a);
+}
+
+overload!((a: &mut A) *= (b: B) { a.0 *= b.0; });
+#[test]
+fn mul_assign() {
+ let mut a = A(3);
+ a *= B(4);
+ assert_eq!(A(3 * 4), a);
+}
+
+overload!((a: &mut A) /= (b: B) { a.0 /= b.0; });
+#[test]
+fn div_assign() {
+ let mut a = A(6);
+ a /= B(3);
+ assert_eq!(A(6 / 3), a);
+}
+
+overload!((a: &mut A) %= (b: B) { a.0 %= b.0; });
+#[test]
+fn rem_assign() {
+ let mut a = A(6);
+ a %= B(4);
+ assert_eq!(A(6 % 4), a);
+}
+
+overload!((a: &mut A) &= (b: B) { a.0 &= b.0; });
+#[test]
+fn bitand_assign() {
+ let mut a = A(6);
+ a &= B(4);
+ assert_eq!(A(6 & 4), a);
+}
+
+overload!((a: &mut A) |= (b: B) { a.0 |= b.0; });
+#[test]
+fn bitor_assign() {
+ let mut a = A(6);
+ a |= B(4);
+ assert_eq!(A(6 | 4), a);
+}
+
+overload!((a: &mut A) ^= (b: B) { a.0 ^= b.0; });
+#[test]
+fn bitxor_assign() {
+ let mut a = A(6);
+ a ^= B(4);
+ assert_eq!(A(6 ^ 4), a);
+}
+
+overload!((a: &mut A) <<= (b: B) { a.0 <<= b.0; });
+#[test]
+fn shl_assign() {
+ let mut a = A(6);
+ a <<= B(4);
+ assert_eq!(A(6 << 4), a);
+}
+
+overload!((a: &mut A) >>= (b: B) { a.0 >>= b.0; });
+#[test]
+fn shr_assign() {
+ let mut a = A(6);
+ a >>= B(4);
+ assert_eq!(A(6 >> 4), a);
+}
diff --git a/vendor/overload/tests/binary.rs b/vendor/overload/tests/binary.rs
new file mode 100644
index 000000000..2fb209ad3
--- /dev/null
+++ b/vendor/overload/tests/binary.rs
@@ -0,0 +1,72 @@
+extern crate overload;
+use overload::overload;
+use std::ops;
+
+#[derive(PartialEq, Debug)]
+struct A(i32);
+
+#[derive(PartialEq, Debug)]
+struct B(i32);
+
+#[derive(PartialEq, Debug)]
+struct C(i32);
+
+overload!((a: A) + (b: B) -> C { C(a.0 + b.0) });
+#[test]
+fn add() {
+ assert_eq!(A(3) + B(4), C(3 + 4));
+}
+
+overload!((a: A) - (b: B) -> C { C(a.0 - b.0) });
+#[test]
+fn sub() {
+ assert_eq!(A(3) - B(4), C(3 - 4));
+}
+
+overload!((a: A) * (b: B) -> C { C(a.0 * b.0) });
+#[test]
+fn mul() {
+ assert_eq!(A(3) * B(4), C(3 * 4));
+}
+
+overload!((a: A) / (b: B) -> C { C(a.0 / b.0) });
+#[test]
+fn div() {
+ assert_eq!(A(6) / B(3), C(6 / 3));
+}
+
+overload!((a: A) % (b: B) -> C { C(a.0 % b.0) });
+#[test]
+fn rem() {
+ assert_eq!(A(6) % B(4), C(6 % 4));
+}
+
+overload!((a: A) & (b: B) -> C { C(a.0 & b.0) });
+#[test]
+fn bitand() {
+ assert_eq!(A(6) & B(4), C(6 & 4));
+}
+
+overload!((a: A) | (b: B) -> C { C(a.0 | b.0) });
+#[test]
+fn bitor() {
+ assert_eq!(A(6) | B(4), C(6 | 4));
+}
+
+overload!((a: A) ^ (b: B) -> C { C(a.0 ^ b.0) });
+#[test]
+fn bitxor() {
+ assert_eq!(A(6) ^ B(4), C(6 ^ 4));
+}
+
+overload!((a: A) << (b: B) -> C { C(a.0 << b.0) });
+#[test]
+fn shl() {
+ assert_eq!(A(6) << B(4), C(6 << 4));
+}
+
+overload!((a: A) >> (b: B) -> C { C(a.0 >> b.0) });
+#[test]
+fn shr() {
+ assert_eq!(A(6) >> B(4), C(6 >> 4));
+}
diff --git a/vendor/overload/tests/unary.rs b/vendor/overload/tests/unary.rs
new file mode 100644
index 000000000..76a3925fe
--- /dev/null
+++ b/vendor/overload/tests/unary.rs
@@ -0,0 +1,21 @@
+extern crate overload;
+use overload::overload;
+use std::ops;
+
+#[derive(PartialEq, Debug)]
+struct A(i32);
+
+#[derive(PartialEq, Debug)]
+struct B(i32);
+
+overload!(- (a: A) -> B { B(-a.0) });
+#[test]
+fn neg() {
+ assert_eq!(-A(3), B(-3));
+}
+
+overload!(! (a: A) -> B { B(!a.0) });
+#[test]
+fn not() {
+ assert_eq!(!A(3), B(!3));
+}