Update README

Cargo fmt and minor changes
This commit is contained in:
Alex Orlenko 2020-04-17 22:43:50 +01:00
parent 47e8a80c1c
commit f7dc9da107
3 changed files with 6 additions and 7 deletions

View file

@ -20,7 +20,7 @@ modules in Rust.
### Async
Starting from 0.3, mlua supports async/await for all Lua versions. This feature works using Lua [coroutines](https://www.lua.org/manual/5.3/manual.html#2.6) and require running [Thread](https://docs.rs/mlua/latest/mlua/struct.Thread.html).
Starting from 0.3, mlua supports async/await for all Lua versions. This works using Lua [coroutines](https://www.lua.org/manual/5.3/manual.html#2.6) and require running [Thread](https://docs.rs/mlua/latest/mlua/struct.Thread.html) along with enabling `async` feature in `Cargo.toml`.
**Examples**:
- [HTTP Client](examples/async_http_client.rs)

View file

@ -81,10 +81,6 @@ fn main() {
#[cfg(all(feature = "lua51", feature = "luajit"))]
panic!("You can enable only one of the features: lua53, lua52, lua51, luajit");
// Async
// #[cfg(all(feature = "async", not(any(feature = "lua53", feature = "lua52"))))]
// panic!("You can enable async only for: lua53, lua52");
let include_dir = find::probe_lua();
build_glue(&include_dir);
}

View file

@ -2,7 +2,7 @@ use std::collections::HashMap;
use hyper::Client as HyperClient;
use mlua::{Lua, Result, Thread, Error};
use mlua::{Error, Lua, Result, Thread};
#[tokio::main]
async fn main() -> Result<()> {
@ -18,7 +18,10 @@ async fn main() -> Result<()> {
let mut headers = HashMap::new();
for (key, value) in resp.headers().iter() {
headers.entry(key.as_str()).or_insert(Vec::new()).push(value.to_str().unwrap());
headers
.entry(key.as_str())
.or_insert(Vec::new())
.push(value.to_str().unwrap());
}
lua_resp.set("headers", headers)?;