c_arrow/lib.rs
1//! # Description
2//! This Rust library allows you to use the arrow operator `->` to access the field of the row pointer, just like C/C++.
3//! # Usage
4//! `pt![`\<link\>`]`
5//!
6//! get a mutable reference of the pointed field.
7//!
8//! `pt![`\<link\> `=` \<expression\>`];`
9//!
10//! assign expression to the pointed field.
11//!
12//! `pt![`\<link\> `=` \<link\>`];`
13//!
14//! assign the pointed field to the other pointed field.
15//!
16//! ### Explanation
17//! | Objects | Explanations |
18//! | :---: | :---- |
19//! | \<func\> | A function returning the `*mut` pointer of a struct. |
20//! | \<met\> | A method which returns the `*mut` pointer of a struct. |
21//! | \<ptr\>`->`\<field\> | Dereferences and accesses the field. |
22//! | \<struct\>`.`\<field\> | Accesses the field directly. |
23//! | \<link\> | (\<func\> \| \<ptr\> \| \<struct\>) ((`->` \| `.`)(\<field\> \| \<met\>))+ |
24//!
25//! # Example
26//! ```rust
27//! let mut stack: Stack<char> = Stack::new();
28//! "abcdefgh"
29//! .chars()
30//! .for_each(|c| stack.push(c));
31//! unsafe {
32//! use c_arrow::{ pt, ref_pt };
33//! let top_back = pt![stack.top->back];
34//! pt![back_of(top_back)->back->data = 'x'];
35//! pt![stack.top->backs(4)->data = stack.back_of_top()->data];
36//! }
37//! ```
38
39pub mod c_arrow;