graphflo 0.1.0

The graphflo plugin for libflo.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use error::*;
use std::any::Any;
use std::sync::RwLockWriteGuard;
use util::Environment;

pub fn cast_this_mut<'a>(this: &'a mut RwLockWriteGuard<Option<Box<Any + Send + Sync>>>) -> Result<&'a mut Environment> {
    if let Some(some) = this.as_mut() {
        if let Some(some) = Any::downcast_mut(some.as_mut()) {
            Ok(some)
        } else {
            Err(ErrorKind::EnvironmentIsIncorrectType.into())
        }
    } else {
        Err(ErrorKind::EnvironmentNeverSet.into())
    }
}