Update dependencies. Lint.

This commit is contained in:
Gregory Burd 2020-08-05 23:03:58 -04:00
parent 0e63167aab
commit 125306e108
104 changed files with 950 additions and 1027 deletions

View file

@ -14,7 +14,7 @@ authors = [
"Gregory Burd <greg@burd.me>",
]
name = "mentat"
version = "0.12.0"
version = "0.13.0"
build = "build/version.rs"
[features]

View file

@ -11,8 +11,8 @@ path = "lib.rs"
chrono = { version = "~0.4", features = ["serde"] }
enum-set = "~0.0.8"
lazy_static = "~1.4"
indexmap = "~1.3"
ordered-float = { version = "~1.0.2", features = ["serde"] }
indexmap = "~1.5"
ordered-float = { version = "~2.0", features = ["serde"] }
uuid = { version = "~0.8", features = ["v4", "serde"] }
serde = { version = "~1.0", features = ["rc"] }
serde_derive = "~1.0"

View file

@ -52,7 +52,7 @@ use edn::entities::{
mod value_type_set;
pub mod values;
pub use value_type_set::ValueTypeSet;
pub use crate::value_type_set::ValueTypeSet;
#[macro_export]
macro_rules! bail {
@ -109,7 +109,7 @@ pub enum AttributeBitFlags {
}
pub mod attribute {
use TypedValue;
use crate::TypedValue;
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]
pub enum Unique {
@ -373,10 +373,7 @@ impl ValueType {
}
pub fn is_numeric(self) -> bool {
match self {
ValueType::Long | ValueType::Double => true,
_ => false,
}
matches!(self, ValueType::Long | ValueType::Double)
}
}

View file

@ -10,7 +10,7 @@
use enum_set::EnumSet;
use ValueType;
use crate::ValueType;
trait EnumSetExtensions<T: ::enum_set::CLike + Clone> {
/// Return a set containing both `x` and `y`.

View file

@ -7,8 +7,8 @@ workspace = ".."
chrono = { version = "~0.4", features = ["serde"] }
enum-set = "~0.0"
failure = "~0.1"
indexmap = "~1.3"
ordered-float = { version = "~1.0", features = ["serde"] }
indexmap = "~1.5"
ordered-float = { version = "~2.0", features = ["serde"] }
uuid = { version = "~0.8", features = ["v4", "serde"] }
[dependencies.core_traits]

View file

@ -13,7 +13,7 @@ use std::collections::BTreeSet;
use core_traits::{Entid, TypedValue};
use Schema;
use crate::Schema;
pub trait CachedAttributes {
fn is_attribute_cached_reverse(&self, entid: Entid) -> bool;

View file

@ -35,18 +35,18 @@ pub use chrono::{
pub use edn::parse::parse_query;
pub use edn::{Cloned, FromMicros, FromRc, Keyword, ToMicros, Utc, ValueRc};
pub use cache::{CachedAttributes, UpdateableCache};
pub use crate::cache::{CachedAttributes, UpdateableCache};
mod sql_types;
mod tx_report;
/// Core types defining a Mentat knowledge base.
mod types;
pub use tx_report::TxReport;
pub use crate::tx_report::TxReport;
pub use types::ValueTypeTag;
pub use crate::types::ValueTypeTag;
pub use sql_types::{SQLTypeAffinity, SQLValueType, SQLValueTypeSet};
pub use crate::sql_types::{SQLTypeAffinity, SQLValueType, SQLValueTypeSet};
/// Map `Keyword` idents (`:db/ident`) to positive integer entids (`1`).
pub type IdentMap = BTreeMap<Keyword, Entid>;

View file

@ -12,7 +12,7 @@ use std::collections::BTreeSet;
use core_traits::{ValueType, ValueTypeSet};
use types::ValueTypeTag;
use crate::types::ValueTypeTag;
/// Type safe representation of the possible return values from SQLite's `typeof`
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]
@ -62,7 +62,7 @@ impl SQLValueType for ValueType {
/// Returns true if the provided integer is in the SQLite value space of this type. For
/// example, `1` is how we encode `true`.
fn accommodates_integer(&self, int: i64) -> bool {
use ValueType::*;
use crate::ValueType::*;
match *self {
Instant => false, // Always use #inst.
Long | Double => true,
@ -123,8 +123,8 @@ impl SQLValueTypeSet for ValueTypeSet {
#[cfg(test)]
mod tests {
use crate::sql_types::SQLValueType;
use core_traits::ValueType;
use sql_types::SQLValueType;
#[test]
fn test_accommodates_integer() {

View file

@ -14,7 +14,7 @@ use std::collections::BTreeMap;
use core_traits::Entid;
use {DateTime, Utc};
use crate::{DateTime, Utc};
/// A transaction report summarizes an applied transaction.
#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]

View file

@ -10,11 +10,11 @@ syncable = ["serde", "serde_json", "serde_derive"]
[dependencies]
failure = "~0.1"
indexmap = "~1.3"
indexmap = "~1.5"
itertools = "~0.9"
lazy_static = "~1.4"
log = "~0.4"
ordered-float = "~1.0"
ordered-float = "~2.0"
time = "~0.2"
petgraph = "~0.5"
serde = { version = "~1.0", optional = true }

View file

@ -10,19 +10,19 @@
#![allow(dead_code)]
use db::TypedSQLValue;
use crate::db::TypedSQLValue;
use crate::entids;
use db_traits::errors::{DbErrorKind, Result};
use edn;
use edn::entities::Entity;
use edn::symbols;
use edn::types::Value;
use entids;
use core_traits::{values, TypedValue};
use crate::schema::SchemaBuilding;
use crate::types::{Partition, PartitionMap};
use mentat_core::{IdentMap, Schema};
use schema::SchemaBuilding;
use types::{Partition, PartitionMap};
/// The first transaction ID applied to the knowledge base.
///

View file

@ -72,11 +72,11 @@ use mentat_sql::{QueryBuilder, SQLQuery, SQLiteQueryBuilder};
use edn::entities::OpType;
use db::TypedSQLValue;
use crate::db::TypedSQLValue;
use db_traits::errors::{DbError, DbErrorKind, Result};
use watcher::TransactWatcher;
use crate::watcher::TransactWatcher;
// Right now we use BTreeMap, because we expect few cached attributes.
pub type CacheMap<K, V> = BTreeMap<K, V>;
@ -198,9 +198,7 @@ impl AevFactory {
let a: Entid = row.get_unwrap(0);
let e: Entid = row.get_unwrap(1);
let value_type_tag: i32 = row.get_unwrap(3);
let v = TypedValue::from_sql_value_pair(row.get_unwrap(2), value_type_tag)
.map(|x| x)
.unwrap();
let v = TypedValue::from_sql_value_pair(row.get_unwrap(2), value_type_tag).unwrap();
(a, e, self.intern(v))
}
}

View file

@ -25,12 +25,12 @@ use rusqlite::limits::Limit;
use rusqlite::types::{ToSql, ToSqlOutput};
use rusqlite::TransactionBehavior;
use bootstrap;
use {repeat_values, to_namespaced_keyword};
use crate::bootstrap;
use crate::{repeat_values, to_namespaced_keyword};
use edn::{DateTime, Utc, Uuid, Value};
use entids;
use crate::entids;
use core_traits::{attribute, Attribute, AttributeBitFlags, Entid, TypedValue, ValueType};
@ -38,13 +38,13 @@ use mentat_core::{AttributeMap, FromMicros, IdentMap, Schema, ToMicros, ValueRc}
use db_traits::errors::{DbErrorKind, Result};
use metadata;
use schema::SchemaBuilding;
use tx::transact;
use types::{AVMap, AVPair, Partition, PartitionMap, DB};
use crate::metadata;
use crate::schema::SchemaBuilding;
use crate::tx::transact;
use crate::types::{AVMap, AVPair, Partition, PartitionMap, DB};
use crate::watcher::NullWatcher;
use std::convert::TryInto;
use watcher::NullWatcher;
// In PRAGMA foo='bar', `'bar'` must be a constant string (it cannot be a
// bound parameter), so we need to escape manually. According to
@ -314,7 +314,7 @@ fn create_current_partition_view(conn: &rusqlite::Connection) -> Result<()> {
max(e) + 1 AS idx
FROM timelined_transactions WHERE timeline = {} GROUP BY part",
case.join(" "),
::TIMELINE_MAIN
crate::TIMELINE_MAIN
);
conn.execute(&view_stmt, rusqlite::params![])?;
@ -908,6 +908,7 @@ impl MentatStoring for rusqlite::Connection {
// We must keep these computed values somewhere to reference them later, so we can't
// combine this map and the subsequent flat_map.
// (e0, a0, v0, value_type_tag0, added0, flags0)
#[allow(clippy::type_complexity)]
let block: Result<Vec<(i64 /* e */,
i64 /* a */,
ToSqlOutput<'a> /* value */,
@ -984,6 +985,7 @@ impl MentatStoring for rusqlite::Connection {
// We must keep these computed values somewhere to reference them later, so we can't
// combine this map and the subsequent flat_map.
// (e0, a0, v0, value_type_tag0, added0, flags0)
#[allow(clippy::type_complexity)]
let block: Result<Vec<(i64 /* e */,
i64 /* a */,
Option<ToSqlOutput<'a>> /* value */,
@ -1174,7 +1176,7 @@ pub fn update_metadata(
new_schema: &Schema,
metadata_report: &metadata::MetadataReport,
) -> Result<()> {
use metadata::AttributeAlteration::*;
use crate::metadata::AttributeAlteration::*;
// Populate the materialized view directly from datoms (and, potentially in the future,
// transactions). This might generalize nicely as we expand the set of materialized views.
@ -1331,12 +1333,12 @@ mod tests {
use std::borrow::Borrow;
use super::*;
use crate::debug::{tempids, TestConn};
use crate::internal_types::Term;
use core_traits::{attribute, KnownEntid};
use db_traits::errors;
use debug::{tempids, TestConn};
use edn::entities::OpType;
use edn::{self, InternSet};
use internal_types::Term;
use mentat_core::util::Either::*;
use mentat_core::{HasSchema, Keyword};
use std::collections::BTreeMap;

View file

@ -66,23 +66,23 @@ use rusqlite::types::ToSql;
use rusqlite::TransactionBehavior;
use tabwriter::TabWriter;
use bootstrap;
use db::*;
use db::{read_attribute_map, read_ident_map};
use crate::bootstrap;
use crate::db::*;
use crate::db::{read_attribute_map, read_ident_map};
use crate::entids;
use db_traits::errors::Result;
use edn;
use entids;
use core_traits::{Entid, TypedValue, ValueType};
use crate::internal_types::TermWithTempIds;
use crate::schema::SchemaBuilding;
use crate::tx::{transact, transact_terms};
use crate::types::*;
use crate::watcher::NullWatcher;
use edn::entities::{EntidOrIdent, TempId};
use edn::InternSet;
use internal_types::TermWithTempIds;
use mentat_core::{HasSchema, SQLValueType, TxReport};
use schema::SchemaBuilding;
use tx::{transact, transact_terms};
use types::*;
use watcher::NullWatcher;
/// Represents a *datom* (assertion) in the store.
#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]

View file

@ -63,7 +63,8 @@ pub fn might_update_metadata(attribute: Entid) -> bool {
if attribute >= DB_DOC {
return false;
}
match attribute {
matches!(
attribute,
// Idents.
DB_IDENT |
// Schema.
@ -72,19 +73,22 @@ pub fn might_update_metadata(attribute: Entid) -> bool {
DB_INDEX |
DB_IS_COMPONENT |
DB_UNIQUE |
DB_VALUE_TYPE =>
true,
_ => false,
}
DB_VALUE_TYPE
)
}
/// Return 'false' if the given attribute might be used to describe a schema attribute.
pub fn is_a_schema_attribute(attribute: Entid) -> bool {
match attribute {
DB_IDENT | DB_CARDINALITY | DB_FULLTEXT | DB_INDEX | DB_IS_COMPONENT | DB_UNIQUE
| DB_VALUE_TYPE => true,
_ => false,
}
matches!(
attribute,
DB_IDENT
| DB_CARDINALITY
| DB_FULLTEXT
| DB_INDEX
| DB_IS_COMPONENT
| DB_UNIQUE
| DB_VALUE_TYPE
)
}
lazy_static! {

View file

@ -23,10 +23,10 @@ use edn::entities;
use edn::entities::{EntityPlace, OpType, TempId, TxFunction};
use edn::{SpannedValue, ValueAndSpan, ValueRc};
use crate::schema::SchemaTypeChecking;
use crate::types::{AVMap, AVPair, Schema, TransactableValue};
use db_traits::errors;
use db_traits::errors::{DbErrorKind, Result};
use schema::SchemaTypeChecking;
use types::{AVMap, AVPair, Schema, TransactableValue};
impl TransactableValue for ValueAndSpan {
fn into_typed_value(self, schema: &Schema, value_type: ValueType) -> Result<TypedValue> {
@ -82,11 +82,7 @@ impl TransactableValue for ValueAndSpan {
}
fn as_tempid(&self) -> Option<TempId> {
self.inner
.as_text()
.cloned()
.map(TempId::External)
.map(|v| v)
self.inner.as_text().cloned().map(TempId::External)
}
}

View file

@ -60,30 +60,30 @@ mod upsert_resolution;
mod watcher;
// Export these for reference from sync code and tests.
pub use bootstrap::{TX0, USER0, V1_PARTS};
pub use crate::bootstrap::{TX0, USER0, V1_PARTS};
pub static TIMELINE_MAIN: i64 = 0;
pub use schema::{AttributeBuilder, AttributeValidation};
pub use crate::schema::{AttributeBuilder, AttributeValidation};
pub use bootstrap::CORE_SCHEMA_VERSION;
pub use crate::bootstrap::CORE_SCHEMA_VERSION;
use edn::symbols;
pub use entids::DB_SCHEMA_CORE;
pub use crate::entids::DB_SCHEMA_CORE;
pub use db::{new_connection, TypedSQLValue};
pub use crate::db::{new_connection, TypedSQLValue};
#[cfg(feature = "sqlcipher")]
pub use db::{change_encryption_key, new_connection_with_key};
pub use watcher::TransactWatcher;
pub use crate::watcher::TransactWatcher;
pub use tx::{transact, transact_terms};
pub use crate::tx::{transact, transact_terms};
pub use tx_observer::{InProgressObserverTransactWatcher, TxObservationService, TxObserver};
pub use crate::tx_observer::{InProgressObserverTransactWatcher, TxObservationService, TxObserver};
pub use types::{AttributeSet, Partition, PartitionMap, TransactableValue, DB};
pub use crate::types::{AttributeSet, Partition, PartitionMap, TransactableValue, DB};
pub fn to_namespaced_keyword(s: &str) -> Result<symbols::Keyword> {
let splits = [':', '/'];

View file

@ -29,18 +29,18 @@ use failure::ResultExt;
use std::collections::btree_map::Entry;
use std::collections::{BTreeMap, BTreeSet};
use add_retract_alter_set::AddRetractAlterSet;
use crate::add_retract_alter_set::AddRetractAlterSet;
use crate::entids;
use db_traits::errors::{DbErrorKind, Result};
use edn::symbols;
use entids;
use core_traits::{attribute, Entid, TypedValue, ValueType};
use mentat_core::{AttributeMap, Schema};
use schema::{AttributeBuilder, AttributeValidation};
use crate::schema::{AttributeBuilder, AttributeValidation};
use types::EAV;
use crate::types::EAV;
/// An alteration to an attribute.
#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]

View file

@ -10,16 +10,16 @@
#![allow(dead_code)]
use db::TypedSQLValue;
use crate::db::TypedSQLValue;
use db_traits::errors::{DbErrorKind, Result};
use edn;
use edn::symbols;
use core_traits::{attribute, Attribute, Entid, KnownEntid, TypedValue, ValueType};
use crate::metadata;
use crate::metadata::AttributeAlteration;
use mentat_core::{AttributeMap, EntidMap, HasSchema, IdentMap, Schema};
use metadata;
use metadata::AttributeAlteration;
pub trait AttributeValidation {
fn validate<F>(&self, ident: F) -> Result<()>
@ -394,7 +394,7 @@ mod test {
fn add_attribute(schema: &mut Schema, ident: Keyword, entid: Entid, attribute: Attribute) {
schema.entid_map.insert(entid, ident.clone());
schema.ident_map.insert(ident.clone(), entid);
schema.ident_map.insert(ident, entid);
if attribute.component {
schema.component_attributes.push(entid);

View file

@ -22,16 +22,16 @@ use edn::InternSet;
use edn::entities::OpType;
use db;
use db::TypedSQLValue;
use crate::db;
use crate::db::TypedSQLValue;
use tx::{transact_terms_with_action, TransactorAction};
use crate::tx::{transact_terms_with_action, TransactorAction};
use types::PartitionMap;
use crate::types::PartitionMap;
use internal_types::{Term, TermWithoutTempIds};
use crate::internal_types::{Term, TermWithoutTempIds};
use watcher::NullWatcher;
use crate::watcher::NullWatcher;
/// Collects a supplied tx range into an DESC ordered Vec of valid txs,
/// ensuring they all belong to the same timeline.
@ -79,7 +79,7 @@ fn move_transactions_to(
&format!(
"UPDATE timelined_transactions SET timeline = {} WHERE tx IN {}",
new_timeline,
::repeat_values(tx_ids.len(), 1)
crate::repeat_values(tx_ids.len(), 1)
),
&(tx_ids
.iter()
@ -109,7 +109,7 @@ fn reversed_terms_for(
) -> Result<Vec<TermWithoutTempIds>> {
let mut stmt = conn.prepare("SELECT e, a, v, value_type_tag, tx, added FROM timelined_transactions WHERE tx = ? AND timeline = ? ORDER BY tx DESC")?;
let rows = stmt.query_and_then(
&[&tx_id, &::TIMELINE_MAIN],
&[&tx_id, &crate::TIMELINE_MAIN],
|row| -> Result<TermWithoutTempIds> {
let op = if row.get(5)? {
OpType::Retract
@ -141,7 +141,7 @@ pub fn move_from_main_timeline(
txs_from: RangeFrom<Entid>,
new_timeline: Entid,
) -> Result<(Option<Schema>, PartitionMap)> {
if new_timeline == ::TIMELINE_MAIN {
if new_timeline == crate::TIMELINE_MAIN {
bail!(DbErrorKind::NotYetImplemented(
"Can't move transactions to main timeline".to_string()
));
@ -154,7 +154,7 @@ pub fn move_from_main_timeline(
bail!(DbErrorKind::TimelinesMoveToNonEmpty);
}
let txs_to_move = collect_ordered_txs_to_move(conn, txs_from, ::TIMELINE_MAIN)?;
let txs_to_move = collect_ordered_txs_to_move(conn, txs_from, crate::TIMELINE_MAIN)?;
let mut last_schema = None;
for tx_id in &txs_to_move {
@ -199,16 +199,16 @@ mod tests {
use std::borrow::Borrow;
use debug::TestConn;
use crate::debug::TestConn;
use bootstrap;
use crate::bootstrap;
// For convenience during testing.
// Real consumers will perform similar operations when appropriate.
fn update_conn(conn: &mut TestConn, schema: &Option<Schema>, pmap: &PartitionMap) {
match schema {
&Some(ref s) => conn.schema = s.clone(),
&None => (),
Some(ref s) => conn.schema = s.clone(),
None => (),
};
conn.partition_map = pmap.clone();
}
@ -241,7 +241,7 @@ mod tests {
assert_matches!(conn.transactions(), "[]");
assert_eq!(new_partition_map, partition_map0);
conn.partition_map = partition_map0.clone();
conn.partition_map = partition_map0;
let report2 = assert_transact!(conn, t);
let partition_map2 = conn.partition_map.clone();

View file

@ -49,17 +49,17 @@ use std::borrow::Cow;
use std::collections::{BTreeMap, BTreeSet, VecDeque};
use std::iter::once;
use db;
use db::MentatStoring;
use db_traits::errors;
use db_traits::errors::{DbErrorKind, Result};
use edn::{InternSet, Keyword};
use entids;
use internal_types::{
use crate::db;
use crate::db::MentatStoring;
use crate::entids;
use crate::internal_types::{
replace_lookup_ref, AEVTrie, AddAndRetract, KnownEntidOr, LookupRef, LookupRefOrTempId,
TempIdHandle, TempIdMap, Term, TermWithTempIds, TermWithTempIdsAndLookupRefs,
TermWithoutTempIds, TypedValueOr,
};
use db_traits::errors;
use db_traits::errors::{DbErrorKind, Result};
use edn::{InternSet, Keyword};
use mentat_core::util::Either;
@ -67,15 +67,15 @@ use core_traits::{attribute, now, Attribute, Entid, KnownEntid, TypedValue, Valu
use mentat_core::{DateTime, Schema, TxReport, Utc};
use crate::metadata;
use crate::schema::SchemaBuilding;
use crate::tx_checking;
use crate::types::{AVMap, AVPair, PartitionMap, TransactableValue};
use crate::upsert_resolution::{FinalPopulations, Generation};
use crate::watcher::TransactWatcher;
use edn::entities as entmod;
use edn::entities::{AttributePlace, Entity, OpType, TempId};
use metadata;
use rusqlite;
use schema::SchemaBuilding;
use tx_checking;
use types::{AVMap, AVPair, PartitionMap, TransactableValue};
use upsert_resolution::{FinalPopulations, Generation};
use watcher::TransactWatcher;
/// Defines transactor's high level behaviour.
pub(crate) enum TransactorAction {
@ -1058,6 +1058,7 @@ where
)
}
#[allow(clippy::too_many_arguments)]
pub(crate) fn transact_terms_with_action<'conn, 'a, I, W>(
conn: &'conn rusqlite::Connection,
partition_map: PartitionMap,

View file

@ -14,7 +14,7 @@ use core_traits::{Entid, TypedValue, ValueType};
use db_traits::errors::CardinalityConflict;
use internal_types::AEVTrie;
use crate::internal_types::AEVTrie;
/// Map from found [e a v] to expected type.
pub(crate) type TypeDisagreements = BTreeMap<(Entid, Entid, TypedValue), ValueType>;

View file

@ -24,11 +24,12 @@ use edn::entities::OpType;
use db_traits::errors::Result;
use types::AttributeSet;
use crate::types::AttributeSet;
use watcher::TransactWatcher;
use crate::watcher::TransactWatcher;
pub struct TxObserver {
#[allow(clippy::type_complexity)]
notify_fn: Arc<Box<dyn Fn(&str, IndexMap<&Entid, &AttributeSet>) + Send + Sync>>,
attributes: AttributeSet,
}
@ -131,6 +132,7 @@ impl TxObservationService {
}
let executor = self.executor.get_or_insert_with(|| {
#[allow(clippy::type_complexity)]
let (tx, rx): (
Sender<Box<dyn Command + Send>>,
Receiver<Box<dyn Command + Send>>,

View file

@ -18,19 +18,19 @@ use std::collections::{BTreeMap, BTreeSet};
use indexmap;
use petgraph::unionfind;
use db_traits::errors::{DbErrorKind, Result};
use internal_types::{
use crate::internal_types::{
Population, TempIdHandle, TempIdMap, Term, TermWithTempIds, TermWithoutTempIds, TypedValueOr,
};
use types::AVPair;
use crate::types::AVPair;
use db_traits::errors::{DbErrorKind, Result};
use mentat_core::util::Either::*;
use core_traits::{attribute, Attribute, Entid, TypedValue};
use crate::schema::SchemaBuilding;
use edn::entities::OpType;
use mentat_core::Schema;
use schema::SchemaBuilding;
/// A "Simple upsert" that looks like [:db/add TEMPID a v], where a is :db.unique/identity.
#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]

View file

@ -12,8 +12,8 @@ readme = "./README.md"
[dependencies]
chrono = "~0.4"
itertools = "~0.9"
num = "~0.2"
ordered-float = "~1.0"
num = "~0.3"
ordered-float = "~2.0"
pretty = "~0.10"
uuid = { version = "~0.8", features = ["v4", "serde"] }
serde = { version = "~1.0", optional = true }

View file

@ -13,11 +13,11 @@
use std::collections::BTreeMap;
use std::fmt;
use value_rc::ValueRc;
use crate::value_rc::ValueRc;
use symbols::{Keyword, PlainSymbol};
use crate::symbols::{Keyword, PlainSymbol};
use types::ValueAndSpan;
use crate::types::ValueAndSpan;
/// `EntityPlace` and `ValuePlace` embed values, either directly (i.e., `ValuePlace::Atom`) or
/// indirectly (i.e., `EntityPlace::LookupRef`). In order to maintain the graph of `Into` and

View file

@ -14,7 +14,7 @@ use std::collections::HashSet;
use std::hash::Hash;
use std::ops::{Deref, DerefMut};
use ValueRc;
use crate::ValueRc;
/// An `InternSet` allows to "intern" some potentially large values, maintaining a single value
/// instance owned by the `InternSet` and leaving consumers with lightweight ref-counted handles to

View file

@ -25,7 +25,7 @@ extern crate serde_derive;
pub mod entities;
pub mod intern_set;
pub use intern_set::InternSet;
pub use crate::intern_set::InternSet;
// Intentionally not pub.
pub mod matcher;
mod namespaceable_name;
@ -35,7 +35,7 @@ pub mod symbols;
pub mod types;
pub mod utils;
pub mod value_rc;
pub use value_rc::{Cloned, FromRc, ValueRc};
pub use crate::value_rc::{Cloned, FromRc, ValueRc};
// Re-export the types we use.
pub use chrono::{DateTime, Utc};
@ -44,11 +44,11 @@ pub use ordered_float::OrderedFloat;
pub use uuid::Uuid;
// Export from our modules.
pub use types::{
pub use crate::types::{
FromMicros, FromMillis, Span, SpannedValue, ToMicros, ToMillis, Value, ValueAndSpan,
};
pub use symbols::{Keyword, NamespacedSymbol, PlainSymbol};
pub use crate::symbols::{Keyword, NamespacedSymbol, PlainSymbol};
use std::collections::{BTreeMap, BTreeSet, LinkedList};
use std::f64::{INFINITY, NAN, NEG_INFINITY};
@ -56,8 +56,8 @@ use std::iter::FromIterator;
use chrono::TimeZone;
use entities::*;
use query::FromValue;
use crate::entities::*;
use crate::query::FromValue;
// Goal: Be able to parse https://github.com/edn-format/edn
// Also extensible to help parse http://docs.datomic.com/query.html
@ -311,7 +311,7 @@ peg::parser!(pub grammar parse() for str {
/ __ v:atom() __ { ValuePlace::Atom(v) }
pub rule entity() -> Entity<ValueAndSpan>
= __ "[" __ op:(op()) __ e:(entity_place()) __ a:(forward_entid()) __ v:(value_place()) __ "]" __ { Entity::AddOrRetract { op, e: e, a: AttributePlace::Entid(a), v: v } }
= __ "[" __ op:(op()) __ e:(entity_place()) __ a:(forward_entid()) __ v:(value_place()) __ "]" __ { Entity::AddOrRetract { op, e, a: AttributePlace::Entid(a), v } }
/ __ "[" __ op:(op()) __ e:(value_place()) __ a:(backward_entid()) __ v:(entity_place()) __ "]" __ { Entity::AddOrRetract { op, e: v, a: AttributePlace::Entid(a), v: e } }
/ __ map:map_notation() __ { Entity::MapNotation(map) }
/ expected!("entity")
@ -353,7 +353,7 @@ peg::parser!(pub grammar parse() for str {
query::PullAttributeSpec::Attribute(
query::NamedPullAttribute {
attribute,
alias: alias,
alias,
})
}
@ -470,7 +470,7 @@ peg::parser!(pub grammar parse() for str {
query::WhereClause::Pred(
query::Predicate {
operator: func.0,
args: args,
args,
})
}
@ -479,7 +479,7 @@ peg::parser!(pub grammar parse() for str {
query::WhereClause::WhereFn(
query::WhereFn {
operator: func.0,
args: args,
args,
binding,
})
}

View file

@ -12,8 +12,8 @@ use itertools::diff_with;
use std::cell::RefCell;
use std::collections::HashMap;
use symbols;
use types::Value;
use crate::symbols;
use crate::types::Value;
/// A trait defining pattern matching rules for any given pattern of type `T`.
trait PatternMatchingRules<'a, T> {
@ -87,7 +87,7 @@ impl<'a> Matcher<'a> {
where
T: PatternMatchingRules<'a, Value>,
{
use Value::*;
use crate::Value::*;
if T::matches_any(pattern) {
true
@ -140,7 +140,7 @@ impl Value {
#[cfg(test)]
mod test {
use parse;
use crate::parse;
macro_rules! assert_match {
( $pattern:tt, $value:tt, $expected:expr ) => {

View file

@ -309,17 +309,6 @@ mod test {
arr.sort();
assert_eq!(
arr,
[
n0.clone(),
n2.clone(),
n1.clone(),
n3.clone(),
n4.clone(),
n5.clone(),
n6.clone(),
]
);
assert_eq!(arr, [n0, n2, n1, n3, n4, n5, n6,]);
}
}

View file

@ -16,7 +16,7 @@ use pretty;
use std::borrow::Cow;
use std::io;
use types::Value;
use crate::types::Value;
impl Value {
/// Return a pretty string representation of this `Value`.
@ -110,7 +110,7 @@ impl Value {
#[cfg(test)]
mod test {
use parse;
use crate::parse;
#[test]
fn test_pp_io() {

View file

@ -35,11 +35,11 @@ use std;
use std::fmt;
use std::rc::Rc;
use {BigInt, DateTime, OrderedFloat, Utc, Uuid};
use crate::{BigInt, DateTime, OrderedFloat, Utc, Uuid};
use value_rc::{FromRc, ValueRc};
use crate::value_rc::{FromRc, ValueRc};
pub use {Keyword, PlainSymbol};
pub use crate::{Keyword, PlainSymbol};
pub type SrcVarName = String; // Do not include the required syntactic '$'.
@ -64,15 +64,15 @@ impl Variable {
}
pub trait FromValue<T> {
fn from_value(v: &::ValueAndSpan) -> Option<T>;
fn from_value(v: &crate::ValueAndSpan) -> Option<T>;
}
/// If the provided EDN value is a PlainSymbol beginning with '?', return
/// it wrapped in a Variable. If not, return None.
/// TODO: intern strings. #398.
impl FromValue<Variable> for Variable {
fn from_value(v: &::ValueAndSpan) -> Option<Variable> {
if let ::SpannedValue::PlainSymbol(ref s) = v.inner {
fn from_value(v: &crate::ValueAndSpan) -> Option<Variable> {
if let crate::SpannedValue::PlainSymbol(ref s) = v.inner {
Variable::from_symbol(s)
} else {
None
@ -115,8 +115,8 @@ impl std::fmt::Display for Variable {
pub struct QueryFunction(pub PlainSymbol);
impl FromValue<QueryFunction> for QueryFunction {
fn from_value(v: &::ValueAndSpan) -> Option<QueryFunction> {
if let ::SpannedValue::PlainSymbol(ref s) = v.inner {
fn from_value(v: &crate::ValueAndSpan) -> Option<QueryFunction> {
if let crate::SpannedValue::PlainSymbol(ref s) = v.inner {
QueryFunction::from_symbol(s)
} else {
None
@ -154,8 +154,8 @@ pub enum SrcVar {
}
impl FromValue<SrcVar> for SrcVar {
fn from_value(v: &::ValueAndSpan) -> Option<SrcVar> {
if let ::SpannedValue::PlainSymbol(ref s) = v.inner {
fn from_value(v: &crate::ValueAndSpan) -> Option<SrcVar> {
if let crate::SpannedValue::PlainSymbol(ref s) = v.inner {
SrcVar::from_symbol(s)
} else {
None
@ -213,8 +213,8 @@ pub enum FnArg {
}
impl FromValue<FnArg> for FnArg {
fn from_value(v: &::ValueAndSpan) -> Option<FnArg> {
use SpannedValue::*;
fn from_value(v: &crate::ValueAndSpan) -> Option<FnArg> {
use crate::SpannedValue::*;
match v.inner {
Integer(x) => Some(FnArg::EntidOrInteger(x)),
PlainSymbol(ref x) if x.is_src_symbol() => SrcVar::from_symbol(x).map(FnArg::SrcVar),
@ -316,16 +316,16 @@ impl PatternNonValuePlace {
}
impl FromValue<PatternNonValuePlace> for PatternNonValuePlace {
fn from_value(v: &::ValueAndSpan) -> Option<PatternNonValuePlace> {
fn from_value(v: &crate::ValueAndSpan) -> Option<PatternNonValuePlace> {
match v.inner {
::SpannedValue::Integer(x) => {
crate::SpannedValue::Integer(x) => {
if x >= 0 {
Some(PatternNonValuePlace::Entid(x))
} else {
None
}
}
::SpannedValue::PlainSymbol(ref x) => {
crate::SpannedValue::PlainSymbol(ref x) => {
if x.0.as_str() == "_" {
Some(PatternNonValuePlace::Placeholder)
} else if let Some(v) = Variable::from_symbol(x) {
@ -334,7 +334,7 @@ impl FromValue<PatternNonValuePlace> for PatternNonValuePlace {
None
}
}
::SpannedValue::Keyword(ref x) => Some(x.clone().into()),
crate::SpannedValue::Keyword(ref x) => Some(x.clone().into()),
_ => None,
}
}
@ -371,45 +371,45 @@ impl From<Keyword> for PatternValuePlace {
}
impl FromValue<PatternValuePlace> for PatternValuePlace {
fn from_value(v: &::ValueAndSpan) -> Option<PatternValuePlace> {
fn from_value(v: &crate::ValueAndSpan) -> Option<PatternValuePlace> {
match v.inner {
::SpannedValue::Integer(x) => Some(PatternValuePlace::EntidOrInteger(x)),
::SpannedValue::PlainSymbol(ref x) if x.0.as_str() == "_" => {
crate::SpannedValue::Integer(x) => Some(PatternValuePlace::EntidOrInteger(x)),
crate::SpannedValue::PlainSymbol(ref x) if x.0.as_str() == "_" => {
Some(PatternValuePlace::Placeholder)
}
::SpannedValue::PlainSymbol(ref x) => {
crate::SpannedValue::PlainSymbol(ref x) => {
Variable::from_symbol(x).map(PatternValuePlace::Variable)
}
::SpannedValue::Keyword(ref x) if x.is_namespaced() => Some(x.clone().into()),
::SpannedValue::Boolean(x) => {
crate::SpannedValue::Keyword(ref x) if x.is_namespaced() => Some(x.clone().into()),
crate::SpannedValue::Boolean(x) => {
Some(PatternValuePlace::Constant(NonIntegerConstant::Boolean(x)))
}
::SpannedValue::Float(x) => {
crate::SpannedValue::Float(x) => {
Some(PatternValuePlace::Constant(NonIntegerConstant::Float(x)))
}
::SpannedValue::BigInteger(ref x) => Some(PatternValuePlace::Constant(
crate::SpannedValue::BigInteger(ref x) => Some(PatternValuePlace::Constant(
NonIntegerConstant::BigInteger(x.clone()),
)),
::SpannedValue::Instant(x) => {
crate::SpannedValue::Instant(x) => {
Some(PatternValuePlace::Constant(NonIntegerConstant::Instant(x)))
}
::SpannedValue::Text(ref x) =>
crate::SpannedValue::Text(ref x) =>
// TODO: intern strings. #398.
{
Some(PatternValuePlace::Constant(x.clone().into()))
}
::SpannedValue::Uuid(ref u) => {
crate::SpannedValue::Uuid(ref u) => {
Some(PatternValuePlace::Constant(NonIntegerConstant::Uuid(*u)))
}
// These don't appear in queries.
::SpannedValue::Nil => None,
::SpannedValue::NamespacedSymbol(_) => None,
::SpannedValue::Keyword(_) => None, // … yet.
::SpannedValue::Map(_) => None,
::SpannedValue::List(_) => None,
::SpannedValue::Set(_) => None,
::SpannedValue::Vector(_) => None,
crate::SpannedValue::Nil => None,
crate::SpannedValue::NamespacedSymbol(_) => None,
crate::SpannedValue::Keyword(_) => None, // … yet.
crate::SpannedValue::Map(_) => None,
crate::SpannedValue::List(_) => None,
crate::SpannedValue::Set(_) => None,
crate::SpannedValue::Vector(_) => None,
}
}
}
@ -882,10 +882,7 @@ pub enum UnifyVars {
impl WhereClause {
pub fn is_pattern(&self) -> bool {
match self {
WhereClause::Pattern(_) => true,
_ => false,
}
matches!(self, WhereClause::Pattern(_))
}
}

View file

@ -10,7 +10,7 @@
use std::fmt::{Display, Formatter, Write};
use namespaceable_name::NamespaceableName;
use crate::namespaceable_name::NamespaceableName;
#[macro_export]
macro_rules! ns_keyword {

View file

@ -25,7 +25,7 @@ use num::BigInt;
use ordered_float::OrderedFloat;
use uuid::Uuid;
use symbols;
use crate::symbols;
/// Value represents one of the allowed values in an EDN string.
#[derive(PartialEq, Eq, Hash, Clone, Debug)]