|
1 | | -use mlua::{FromLua, Lua, Table, UserData}; |
| 1 | +use mlua::{FromLua, IntoLua, Lua, UserData, Value}; |
2 | 2 |
|
3 | 3 | #[derive(Clone, Copy, Default, FromLua)] |
4 | 4 | pub struct Constraint(pub(super) ratatui::layout::Constraint); |
5 | 5 |
|
6 | 6 | impl Constraint { |
7 | | - pub fn compose(lua: &Lua) -> mlua::Result<Table> { |
| 7 | + pub fn compose(lua: &Lua) -> mlua::Result<Value> { |
8 | 8 | use ratatui::layout::Constraint as C; |
9 | 9 |
|
10 | | - lua.create_table_from([ |
11 | | - ("Min", lua.create_function(|_, n: u16| Ok(Self(C::Min(n))))?), |
12 | | - ("Max", lua.create_function(|_, n: u16| Ok(Self(C::Max(n))))?), |
13 | | - ("Length", lua.create_function(|_, n: u16| Ok(Self(C::Length(n))))?), |
14 | | - ("Percentage", lua.create_function(|_, n: u16| Ok(Self(C::Percentage(n))))?), |
15 | | - ("Ratio", lua.create_function(|_, (a, b): (u32, u32)| Ok(Self(C::Ratio(a, b))))?), |
16 | | - ("Fill", lua.create_function(|_, n: u16| Ok(Self(C::Fill(n))))?), |
17 | | - ]) |
| 10 | + lua |
| 11 | + .create_table_from([ |
| 12 | + ("Min", lua.create_function(|_, n: u16| Ok(Self(C::Min(n))))?), |
| 13 | + ("Max", lua.create_function(|_, n: u16| Ok(Self(C::Max(n))))?), |
| 14 | + ("Length", lua.create_function(|_, n: u16| Ok(Self(C::Length(n))))?), |
| 15 | + ("Percentage", lua.create_function(|_, n: u16| Ok(Self(C::Percentage(n))))?), |
| 16 | + ("Ratio", lua.create_function(|_, (a, b): (u32, u32)| Ok(Self(C::Ratio(a, b))))?), |
| 17 | + ("Fill", lua.create_function(|_, n: u16| Ok(Self(C::Fill(n))))?), |
| 18 | + ])? |
| 19 | + .into_lua(lua) |
18 | 20 | } |
19 | 21 | } |
20 | 22 |
|
|
0 commit comments