Update README.md
This commit is contained in:
parent
fbb5b72f24
commit
f69788264e
30
README.md
30
README.md
@ -6,6 +6,16 @@ Rhai is an embedded scripting language for Rust. It is meant to be a safe drop-
|
||||
|
||||
**Note:** Currently, it's pre-0.1, and is likely to change a bit before it stabilizes enough for a crates.io release.
|
||||
|
||||
Rhai's current feature set:
|
||||
|
||||
* Straightforward integration with your application
|
||||
* Fairly efficient (1 mil iterations in 0.75 sec on my 5 year old laptop)
|
||||
* Low compile-time overhead (~4 secs for debug build, ~11 secs for release build)
|
||||
* Simple, easy-to-use scripting language
|
||||
* Support for overloaded functions
|
||||
* No additional dependencies
|
||||
* No unsafe code
|
||||
|
||||
## Variables
|
||||
|
||||
```Rust
|
||||
@ -18,17 +28,36 @@ var x = 3;
|
||||
if true {
|
||||
print("it's true!");
|
||||
}
|
||||
else {
|
||||
print("It's false!");
|
||||
}
|
||||
```
|
||||
|
||||
```Rust
|
||||
var x = 10;
|
||||
while x > 0 {
|
||||
print(x);
|
||||
if x == 5 {
|
||||
break;
|
||||
}
|
||||
x = x - 1;
|
||||
}
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
Rhai supports defining functions in script:
|
||||
|
||||
```Rust
|
||||
fn add(x, y) {
|
||||
return x + y;
|
||||
}
|
||||
|
||||
print(add(2, 3))
|
||||
```
|
||||
|
||||
Just like in Rust, you can also use an implicit return.
|
||||
|
||||
```Rust
|
||||
fn add(x, y) {
|
||||
x + y
|
||||
@ -37,6 +66,7 @@ fn add(x, y) {
|
||||
print(add(2, 3))
|
||||
```
|
||||
|
||||
|
||||
# Example 1: Hello world
|
||||
|
||||
```Rust
|
||||
|
Loading…
Reference in New Issue
Block a user