File tree Expand file tree Collapse file tree 4 files changed +12
-6
lines changed Expand file tree Collapse file tree 4 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -133,8 +133,14 @@ impl<'a> Debug<'a> {
133
133
}
134
134
}
135
135
136
- /// Corresponds to the `l` "what" mask. Returns the current line.
136
+ #[ doc( hidden) ]
137
+ #[ deprecated( note = "Use `current_line` instead" ) ]
137
138
pub fn curr_line ( & self ) -> i32 {
139
+ self . current_line ( ) . map ( |n| n as i32 ) . unwrap_or ( -1 )
140
+ }
141
+
142
+ /// Corresponds to the `l` "what" mask. Returns the current line.
143
+ pub fn current_line ( & self ) -> Option < usize > {
138
144
unsafe {
139
145
#[ cfg( not( feature = "luau" ) ) ]
140
146
mlua_assert ! (
@@ -147,7 +153,7 @@ impl<'a> Debug<'a> {
147
153
"lua_getinfo failed with `l`"
148
154
) ;
149
155
150
- ( * self . ar ) . currentline
156
+ linenumber_to_usize ( ( * self . ar ) . currentline )
151
157
}
152
158
}
153
159
Original file line number Diff line number Diff line change @@ -577,7 +577,7 @@ impl Lua {
577
577
/// # fn main() -> Result<()> {
578
578
/// let lua = Lua::new();
579
579
/// lua.set_hook(HookTriggers::EVERY_LINE, |_lua, debug| {
580
- /// println!("line {}", debug.curr_line ());
580
+ /// println!("line {:? }", debug.current_line ());
581
581
/// Ok(VmState::Continue)
582
582
/// });
583
583
///
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ fn test_line_counts() -> Result<()> {
24
24
let lua = Lua :: new ( ) ;
25
25
lua. set_hook ( HookTriggers :: EVERY_LINE , move |_lua, debug| {
26
26
assert_eq ! ( debug. event( ) , DebugEvent :: Line ) ;
27
- hook_output. lock ( ) . unwrap ( ) . push ( debug. curr_line ( ) ) ;
27
+ hook_output. lock ( ) . unwrap ( ) . push ( debug. current_line ( ) . unwrap ( ) ) ;
28
28
Ok ( VmState :: Continue )
29
29
} ) ?;
30
30
lua. load (
@@ -240,7 +240,7 @@ fn test_hook_threads() -> Result<()> {
240
240
let hook_output = output. clone ( ) ;
241
241
co. set_hook ( HookTriggers :: EVERY_LINE , move |_lua, debug| {
242
242
assert_eq ! ( debug. event( ) , DebugEvent :: Line ) ;
243
- hook_output. lock ( ) . unwrap ( ) . push ( debug. curr_line ( ) ) ;
243
+ hook_output. lock ( ) . unwrap ( ) . push ( debug. current_line ( ) . unwrap ( ) ) ;
244
244
Ok ( VmState :: Continue )
245
245
} ) ?;
246
246
Original file line number Diff line number Diff line change @@ -1283,7 +1283,7 @@ fn test_inspect_stack() -> Result<()> {
1283
1283
. inspect_stack ( 1 , |debug| {
1284
1284
let source = debug. source ( ) . short_src ;
1285
1285
let source = source. as_deref ( ) . unwrap_or ( "?" ) ;
1286
- let line = debug. curr_line ( ) ;
1286
+ let line = debug. current_line ( ) . unwrap ( ) ;
1287
1287
format ! ( "{}:{} {}" , source, line, msg)
1288
1288
} )
1289
1289
. unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments