| Crates.io | yoga-sys |
| lib.rs | yoga-sys |
| version | 0.2.3 |
| created_at | 2017-05-23 17:11:26.380531+00 |
| updated_at | 2017-11-23 20:07:20.812508+00 |
| description | Raw rust bindings for yoga (facebook flex layout cross-platform engine) |
| homepage | https://github.com/Nemikolh/yoga-rs |
| repository | https://github.com/Nemikolh/yoga-rs |
| max_upload_size | |
| id | 15720 |
| size | 229,761 |
Raw rust bindings for yoga.
Disclaimer: Those bindings are not provided by any of the facebook maintainers and thus may contains additional bugs.
Add to your Cargo.toml:
[dependencies]
yoga-sys = "0.2.3"
In your main.rs or lib.rs file add:
extern crate yoga_sys;
Here is the example that you can find here translated to rust using this crate:
extern crate yoga_sys;
use yoga_sys::*;
fn main() {
unsafe {
let root = YGNodeNew();
YGNodeStyleSetWidth(root, 500.);
YGNodeStyleSetHeight(root, 120.);
YGNodeStyleSetFlexDirection(root, YGFlexDirection::YGFlexDirectionRow);
YGNodeStyleSetPadding(root, YGEdge::YGEdgeAll, 20.);
let image = YGNodeNew();
YGNodeStyleSetWidth(image, 80.);
YGNodeStyleSetMargin(image, YGEdge::YGEdgeEnd, 20.);
let text = YGNodeNew();
YGNodeStyleSetHeight(text, 25.);
YGNodeStyleSetAlignSelf(text, YGAlign::YGAlignCenter);
YGNodeStyleSetFlexGrow(text, 1.);
YGNodeInsertChild(root, image, 0);
YGNodeInsertChild(root, text, 1);
YGNodeFreeRecursive(root);
}
}