use crate::mem::own;
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BinaryOperation {
pub left: Box<crate::Expression>,
pub operator: crate::BinaryOperator,
pub right: Box<crate::Expression>,
}
impl BinaryOperation {
pub fn span(&self) -> crate::Span {
crate::Span { start: self.start().into(), end: self.end().into() }
}
pub fn start(&self) -> crate::Position {
self.left.start()
}
pub fn end(&self) -> crate::Position {
self.right.end()
}
}
impl std::convert::From<*mut crate::ffi::any> for BinaryOperation {
fn from(ptr: *mut crate::ffi::any) -> Self {
let crate::ffi::BinaryOperation { operator_: operator, left, right } =
own(ptr);
Self {
operator: crate::BinaryOperator::from(operator),
left: Box::new(crate::Expression::from(left)),
right: Box::new(crate::Expression::from(right)),
}
}
}