Hello.
How to implement add-assign ?
Error:
error[E0277]: cannot add-assign
bool
tobool
--> src/main.rs:146:41
|
146 | ... dh_addr.do_send(data);
| ^^^^ no implementation forbool += bool
|
= help: the traitstd::ops::AddAssign
is not implemented forbool
= note: required because of the requirements on the impl ofactix::handler::Handler<datahub::Data<bool>>
fordatahub::DataHub
My Code:
let value = true as bool;
mytActor.do_send(Data::new_out("myID".to_string(), value));
...
#[derive(Debug, Clone)]
pub enum Direction
{
Out,
In,
}
impl Default for Direction {
fn default() -> Self { Direction::In }
}
#[derive(Debug, Clone, Default)]
pub struct Data<T> {
pub value: T,
pub id: String,
pub dir : Direction,
}
impl<T: std::default::Default> Data<T> {
pub fn new( t: T ) -> Data<T>
{
let mut data = Data::default();
data.value = t;
return data;
}
pub fn new_out( id : String, t: T ) -> Data<T>
{
let mut data = Data::new(t);
data.dir = Direction::Out;
data.id = id;
return data;
}
}
impl<T: 'static> Message for Data<T> {
type Result = T;
}
impl AddAssign<bool> for Data<bool>
{
fn add_assign(&mut self, rhs: bool) {
self.value = rhs;
}
}