Skip to content

Commit 032cab1

Browse files
committed
Add more details on library usage
1 parent dda0aef commit 032cab1

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

Diff for: README.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
11
# Rust prefix to postfix
2-
## This is a prefix to postfix notation converter programmed in rust that uses the shunting yard algorithm
2+
### A prefix to postfix notation converter programmed in rust that uses the shunting yard algorithm
3+
4+
## Usage
5+
1. Place the library inside your project, in this case test_rust_prefix_to_postfix. Then add rust_prefix_to_postfix = {path = "rust_prefix_to_postfix to the dependencies like below
6+
```
7+
[package]
8+
name = "test_rust_prefix_to_postfix"
9+
version = "0.1.0"
10+
edition = "2018"
11+
12+
13+
[dependencies]
14+
rust_prefix_to_postfix = {path = "rust_prefix_to_postfix
15+
```
16+
2. Use call the trait in the library and add a new infix operation
17+
```Rust
18+
use rust_prefix_to_postfix::Operation;
19+
20+
fn main() {
21+
let op_info_r = rust_prefix_to_postfix::OperationInfo::new(&"122+((2^2)*3-1)-(2^2)+2-sqrt(5*7+3)".to_string());
22+
23+
if op_info_r.is_ok() {
24+
let mut op_info = op_info_r.unwrap();
25+
match op_info.reverse_polish_parsing() {
26+
Err(e) => println!("{:?}", e),
27+
Ok(_) => (),
28+
};
29+
println!("{:?}", op_info.infix);
30+
println!("{:?}", op_info.reverse_pn);
31+
}
32+
}
33+
```

0 commit comments

Comments
 (0)