phlow_extensions/
lib.rs

1#![allow(incomplete_features)]
2#![feature(specialization)]
3
4#[macro_use]
5extern crate phlow;
6
7mod extensions_f32;
8mod extensions_integer;
9mod extensions_rc;
10mod extensions_string;
11mod extensions_vec;
12
13define_extensions!(CoreExtensions);
14import_extensions!(CoreExtensions);
15
16#[macro_export]
17macro_rules! representations_view_for_integer {
18    ($extension_name:ident, $integer_type:ident) => {
19        #[phlow::extensions(CoreExtensions, $integer_type)]
20        impl $extension_name {
21            #[phlow::view]
22            fn representations_for(
23                _this: &$integer_type,
24                view: impl phlow::PhlowView,
25            ) -> impl phlow::PhlowView {
26                view.columned_list()
27                    .title("Info")
28                    .priority(5)
29                    .items::<$integer_type>(|number| {
30                        phlow_all!(vec![
31                            ("Decimal", phlow!(number.clone())),
32                            ("Hex", phlow!(format!("{:X}", number))),
33                            ("Octal", phlow!(format!("{:o}", number))),
34                            ("Binary", phlow!(format!("{:b}", number)))
35                        ])
36                    })
37                    .column_item::<(&str, phlow::PhlowObject)>("Representation", |each| {
38                        phlow!(each.0.clone())
39                    })
40                    .column_item::<(&str, phlow::PhlowObject)>("Value", |each| {
41                        phlow!(each.1.clone())
42                    })
43                    .send::<(&str, phlow::PhlowObject)>(|each| each.1.clone())
44            }
45        }
46    };
47}