Skip to content

Commit

Permalink
Fully qualify traits in macros
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonasher committed May 21, 2024
1 parent ea86a20 commit 1768b5f
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ macro_rules! define_plugin {
($plugin:ident, $data_container:ty, $default: expr) => {
struct $plugin {}

impl Plugin for $plugin {
impl $crate::context::Plugin for $plugin {
type DataContainer = $data_container;

fn get_data_container() -> Self::DataContainer {
Expand Down
9 changes: 4 additions & 5 deletions src/global_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::any::{Any, TypeId};
use std::collections::HashMap;
use std::rc::Rc;

use crate::context::{Context, Plugin};
use crate::context::Context;
use crate::data_containers::heterogeneous_container::HeterogeneousContainer;
use crate::data_containers::Property;

Expand All @@ -14,11 +14,11 @@ macro_rules! define_global_property {
($global_property:ident, $value:ty) => {
pub struct $global_property {}

impl Property for $global_property {
impl $crate::data_containers::Property for $global_property {
type Value = $value;
}

impl GlobalProperty for $global_property {}
impl $crate::global_properties::GlobalProperty for $global_property {}
};
}
pub use define_global_property;
Expand Down Expand Up @@ -121,8 +121,7 @@ impl GlobalPropertyContext for Context {
#[cfg(test)]
mod test {
use crate::context::Context;
use crate::data_containers::Property;
use crate::global_properties::{GlobalProperty, GlobalPropertyContext};
use crate::global_properties::GlobalPropertyContext;

define_global_property!(PropertyA, usize);

Expand Down
2 changes: 1 addition & 1 deletion src/groups.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::context::{Context, Plugin};
use crate::context::Context;
use crate::data_containers::vector_person_container::VecPersonContainer;
use crate::data_containers::{PersonContainer, PropertyWithDefault};
use crate::people::PersonId;
Expand Down
8 changes: 3 additions & 5 deletions src/partitions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate rand;

use crate::context::{Context, Plugin};
use crate::context::Context;
use crate::data_containers::indexset_person_container::IndexSetPersonContainer;
use crate::data_containers::PersonContainer;
use crate::people::{PeopleContext, PersonId};
Expand Down Expand Up @@ -305,13 +305,11 @@ impl InternalPartitionContext for Context {
#[cfg(test)]
mod test {
use crate::context::Context;
use crate::data_containers::{PersonContainer, PropertyWithDefault};
use crate::data_containers::PersonContainer;
use crate::define_person_property;
use crate::partitions::{Partition, PartitionContext};
use crate::people::{PeopleContext, PersonId};
use crate::person_properties::{
PersonProperty, PersonPropertyContext, PersonPropertyPartitionBuilder,
};
use crate::person_properties::{PersonPropertyContext, PersonPropertyPartitionBuilder};
use rand::prelude::StdRng;
use rand::{Rng, SeedableRng};
use std::collections::HashSet;
Expand Down
4 changes: 2 additions & 2 deletions src/people.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::context::{Context, Plugin};
use crate::context::Context;
use crate::creation::CreationBuilder;
use std::any::{Any, TypeId};
use std::cell::RefCell;
Expand Down Expand Up @@ -139,7 +139,7 @@ impl PeopleContext for Context {

#[cfg(test)]
mod tests {
use crate::context::{Context, Plugin};
use crate::context::Context;

use super::{PeopleContext, PersonId};

Expand Down
13 changes: 6 additions & 7 deletions src/person_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::any::{Any, TypeId};
use std::collections::HashMap;
use std::rc::Rc;

use crate::context::{Context, Plugin};
use crate::context::Context;
use crate::data_containers::vector_heterogeneous_container::VecDataContainer;
use crate::data_containers::PropertyWithDefault;
use crate::partitions::{Partition, PartitionBuilder, PartitionUpdateCallbackProvider};
Expand All @@ -15,31 +15,31 @@ macro_rules! define_person_property {
($person_property:ident, $value:ty, $default: expr) => {
pub struct $person_property {}

impl PropertyWithDefault for $person_property {
impl $crate::data_containers::PropertyWithDefault for $person_property {
type Value = $value;

fn get_default() -> Self::Value {
$default
}
}

impl PersonProperty for $person_property {}
impl $crate::person_properties::PersonProperty for $person_property {}
};
}
pub use define_person_property;

#[macro_export]
macro_rules! define_person_property_from_enum {
($person_property:ty, $default: expr) => {
impl PropertyWithDefault for $person_property {
impl $crate::data_containers::PropertyWithDefault for $person_property {
type Value = $person_property;

fn get_default() -> Self::Value {
$default
}
}

impl PersonProperty for $person_property {}
impl $crate::person_properties::PersonProperty for $person_property {}

impl Copy for $person_property {}

Expand Down Expand Up @@ -233,10 +233,9 @@ impl<'a, P: Partition> PersonPropertyPartitionBuilder<'a, P> for PartitionBuilde
#[cfg(test)]
mod test {
use crate::context::{Component, Context};
use crate::data_containers::PropertyWithDefault;
use crate::people::PeopleContext;
use crate::person_properties::{
PersonId, PersonPropertiesPersonBuilder, PersonProperty, PersonPropertyContext,
PersonId, PersonPropertiesPersonBuilder, PersonPropertyContext,
};

define_person_property!(PropertyOne, usize, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/random.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::context::{Context, Plugin};
use crate::context::Context;
use rand::SeedableRng;
use std::any::{Any, TypeId};
use std::cell::{RefCell, RefMut};
Expand Down
14 changes: 7 additions & 7 deletions src/regions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::context::{Context, Plugin};
use crate::context::Context;
use crate::creation::CreationBuilder;
use crate::data_containers::vector_heterogeneous_container::VecDataContainer;
use crate::data_containers::PropertyWithDefault;
Expand Down Expand Up @@ -26,15 +26,15 @@ macro_rules! define_region_property {
($region_property:ident, $value:ty, $default: expr) => {
pub struct $region_property {}

impl PropertyWithDefault for $region_property {
impl $crate::data_containers::PropertyWithDefault for $region_property {
type Value = $value;

fn get_default() -> Self::Value {
$default
}
}

impl RegionProperty for $region_property {}
impl $crate::regions::RegionProperty for $region_property {}
};
}
pub use define_region_property;
Expand Down Expand Up @@ -271,13 +271,13 @@ impl<'a, P: Partition> RegionsPartitionBuilder<'a, P> for PartitionBuilder<'a, P

#[cfg(test)]
mod test {
use crate::context::{Component, Context, Plugin};
use crate::data_containers::{PersonContainer, PropertyWithDefault};
use crate::context::{Component, Context};
use crate::data_containers::PersonContainer;
use crate::partitions::{Partition, PartitionContext};
use crate::people::PeopleContext;
use crate::regions::{
RegionId, RegionPropertiesCreationBuilder, RegionProperty, RegionsContext,
RegionsPartitionBuilder, RegionsPersonBuilder,
RegionId, RegionPropertiesCreationBuilder, RegionsContext, RegionsPartitionBuilder,
RegionsPersonBuilder,
};

define_region_property!(RegionPropertyA, f64, 0.0);
Expand Down
4 changes: 2 additions & 2 deletions src/reports.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::context::{Context, Plugin};
use crate::context::Context;
use serde::Serialize;
use std::any::{Any, TypeId};
use std::collections::HashMap;
Expand Down Expand Up @@ -113,7 +113,7 @@ where

#[cfg(test)]
mod test {
use crate::context::{Context, Plugin};
use crate::context::Context;
use crate::reports::{
get_channel_report_handler, get_file_report_handler, Report, ReportsContext,
};
Expand Down

0 comments on commit 1768b5f

Please sign in to comment.