From f69788264e12939670fef78c6f9ebc073505a0c6 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 3 Mar 2016 09:59:53 -0500 Subject: [PATCH] Update README.md --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index b556500d..9b81012e 100644 --- a/README.md +++ b/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