extend readme a bit

This commit is contained in:
Robin Appelman 2019-04-05 21:35:33 +02:00
commit d9e7a104ce

View file

@ -1,6 +1,6 @@
# Ivory # Ivory
Writing php extensions in rust Writing php extensions in rust made easy
## Usage ## Usage
@ -8,14 +8,28 @@ Writing php extensions in rust
use ivory::{ivory_export, ivory_module}; use ivory::{ivory_export, ivory_module};
use ivory::externs::printf; use ivory::externs::printf;
/// Basic methods
#[ivory_export]
fn hello_world() {
printf("Hello world, Rust!");
}
/// Automatically casts function arguments for php
#[ivory_export] #[ivory_export]
fn hello_other(other: String) { fn hello_other(other: String) {
printf(format!("Hello {}", other)); printf(format!("Hello {}", other));
} }
/// And casts return types back to php
#[ivory_export] #[ivory_export]
fn hello_world() { fn add_one(input: i64) -> i64 {
printf("Hello world, Rust!"); input + 1
}
/// Optional arguments
#[ivory_export]
fn hello(input: Option<String>) {
printf(format!("Hello {}", other.unwrap_or("Rust".to_string())));
} }
ivory_module!({ ivory_module!({