use crate::rust::RustType;
use crate::{CodeBuffer, Expression};
pub trait WithResult: Sized {
fn result(&self) -> Option<&RustType>;
fn set_result<T>(&mut self, result: T)
where
T: Into<RustType>;
#[must_use]
fn with_result<T>(mut self, result: T) -> Self
where
T: Into<RustType>,
{
self.set_result(result);
self
}
fn write_result(&self, b: &mut CodeBuffer) {
if let Some(result) = self.result() {
b.write(" -> ");
result.write(b);
}
}
}