ptal / intervallum

Integer interval arithmetic library
Apache License 2.0
17 stars 7 forks source link

Error: union not implemented #17

Closed adfaure closed 6 years ago

adfaure commented 7 years ago

Hello, I try to compile the example provided in the documentation and I am getting an error. My understanding of rust is still pretty low...

Thank you for your help!

Here is the error:

error: no method named `union` found for type `interval::IntervalSet<i32>` in the current scope
  --> src/main.rs:26:18
   |
26 |     assert_eq!(a.union(&b), a_union_b);
   |                  ^^^^^
   |
   = help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
   = help: candidate #1: `use gcollections::ops::set::Union;`

Some information:

[nix-shell:~/Projects/rustbs/rustbatsim]$ rustc --version                                                                                                     rustc 1.16.0-nightly 

My Cargo.toml's dependencies:

[dependencies]
intervallum = {git = "https://github.com/ptal/intervallum"}
gcollections = {git = "https://github.com/ptal/gcollections"}                                                                                                                       

And here is my main:

extern crate interval;
extern crate gcollections;

use gcollections::ops::*;
use interval::interval_set::*;

fn main() {
   let a: interval::IntervalSet<i32> = vec![(1,2), (6,10)].to_interval_set();
   let b = vec![(3,5), (7,7)].to_interval_set();
   let a_union_b = vec![(1,5), (6,10)].to_interval_set();
   let a_intersect_b = vec![(7,7)].to_interval_set();

   assert_eq!(a.union(&b), a_union_b);
 }
ptal commented 6 years ago

Wow, sorry I'm a bit late on this one, I was not notified of the issue... Your code works well on the newest versions of gcollections, it was not working before because the trait Union was not imported into your project, but now it is automatically imported from gcollections::ops::*.