mirror of
https://github.com/icewind1991/ivory.git
synced 2026-06-03 10:44:09 +02:00
extend readme a bit
This commit is contained in:
parent
caf346e4c7
commit
d9e7a104ce
1 changed files with 17 additions and 3 deletions
20
README.md
20
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# Ivory
|
||||
|
||||
Writing php extensions in rust
|
||||
Writing php extensions in rust made easy
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
@ -8,14 +8,28 @@ Writing php extensions in rust
|
|||
use ivory::{ivory_export, ivory_module};
|
||||
use ivory::externs::printf;
|
||||
|
||||
/// Basic methods
|
||||
#[ivory_export]
|
||||
fn hello_world() {
|
||||
printf("Hello world, Rust!");
|
||||
}
|
||||
|
||||
/// Automatically casts function arguments for php
|
||||
#[ivory_export]
|
||||
fn hello_other(other: String) {
|
||||
printf(format!("Hello {}", other));
|
||||
}
|
||||
|
||||
/// And casts return types back to php
|
||||
#[ivory_export]
|
||||
fn hello_world() {
|
||||
printf("Hello world, Rust!");
|
||||
fn add_one(input: i64) -> i64 {
|
||||
input + 1
|
||||
}
|
||||
|
||||
/// Optional arguments
|
||||
#[ivory_export]
|
||||
fn hello(input: Option<String>) {
|
||||
printf(format!("Hello {}", other.unwrap_or("Rust".to_string())));
|
||||
}
|
||||
|
||||
ivory_module!({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue