using_any/
using_any.rs

1use kdb::{cast, try_cast, Any, Atom, KBox};
2
3fn main() {
4    let int = KBox::new_atom(42);
5
6    // convert to an "any" value:
7    let any: KBox<Any> = int.into();
8
9    // convert back to an i32 atom.
10    let int = cast!(any; Atom<i32>);
11    println!("{:?}", int);
12
13    let any: KBox<Any> = int.into();
14    // try to convert to a u8 atom. This will fail!
15    if let Err(e) = try_cast!(any; Atom<u8>) {
16        println!("Error: {}", e);
17    }
18}