Skip to content

0.2.0

Compare
Choose a tag to compare
@GlenDC GlenDC released this 15 Apr 09:36
· 26 commits to main since this release

Breaking Changes:

  • Support Option in a special way:
    • for filters it means that both positive and negative bits will be set to false if the value is None;
    • for filter maps this means that the filter is not even registered;
    • keys cannot be optional;
      • While technically this is a breaking change it is not expected to actually break someone,
        as keys always had to be unique already and two times None will result in same hash... so it is unlikely
        that there was an Option<T> already used by someone;
    • this is potentially breaking as some implementations from 0.1* might have already used Option in a different way;

While this changes behaviour of filters and filter maps it is unlikely that someone was already using
Option<T> for these types before, as their ergonomics have been a bit weird prior to this version.
Even more so for filter maps it could have resulted in panics.

Updated Example from 0.1:

use venndb::VennDB

#[derive(Debug, VennDB)]
pub struct Employee {
    #[venndb(key)]
    id: u32,
    name: String,
    is_manager: Option<bool>,
    is_admin: bool,
    #[venndb(skip)]
    foo: bool,
    #[venndb(filter)]
    department: Department,
    #[venndb(filter)]
    country: Option<String>,
}

fn main() {
    let db = EmployeeDB::from_iter(/* .. */);

    let mut query = db.query();
    let employee = query
        .is_admin(true)
        .is_manager(false)  // rows which have `None` for this property will NOT match this filter
        .department(Department::Engineering)
        .execute()
        .expect("to have found at least one")
        .any();

    println!("non-manager admin engineer: {:?}", employee);
    // as we didn't specify a `country` filter, even rows without a country specified will
    // match here if they match the defined (query) filters)
}

Non-Breaking Changes:

  • improve documentation;