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> {
133133 }
134134 }
135135
136- /// Corresponds to the `l` "what" mask. Returns the current line.
136+ #[ doc( hidden) ]
137+ #[ deprecated( note = "Use `current_line` instead" ) ]
137138 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 > {
138144 unsafe {
139145 #[ cfg( not( feature = "luau" ) ) ]
140146 mlua_assert ! (
@@ -147,7 +153,7 @@ impl<'a> Debug<'a> {
147153 "lua_getinfo failed with `l`"
148154 ) ;
149155
150- ( * self . ar ) . currentline
156+ linenumber_to_usize ( ( * self . ar ) . currentline )
151157 }
152158 }
153159
Original file line number Diff line number Diff line change @@ -577,7 +577,7 @@ impl Lua {
577577 /// # fn main() -> Result<()> {
578578 /// let lua = Lua::new();
579579 /// lua.set_hook(HookTriggers::EVERY_LINE, |_lua, debug| {
580- /// println!("line {}", debug.curr_line ());
580+ /// println!("line {:? }", debug.current_line ());
581581 /// Ok(VmState::Continue)
582582 /// });
583583 ///
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ fn test_line_counts() -> Result<()> {
2424 let lua = Lua :: new ( ) ;
2525 lua. set_hook ( HookTriggers :: EVERY_LINE , move |_lua, debug| {
2626 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 ( ) ) ;
2828 Ok ( VmState :: Continue )
2929 } ) ?;
3030 lua. load (
@@ -240,7 +240,7 @@ fn test_hook_threads() -> Result<()> {
240240 let hook_output = output. clone ( ) ;
241241 co. set_hook ( HookTriggers :: EVERY_LINE , move |_lua, debug| {
242242 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 ( ) ) ;
244244 Ok ( VmState :: Continue )
245245 } ) ?;
246246
Original file line number Diff line number Diff line change @@ -1283,7 +1283,7 @@ fn test_inspect_stack() -> Result<()> {
12831283 . inspect_stack ( 1 , |debug| {
12841284 let source = debug. source ( ) . short_src ;
12851285 let source = source. as_deref ( ) . unwrap_or ( "?" ) ;
1286- let line = debug. curr_line ( ) ;
1286+ let line = debug. current_line ( ) . unwrap ( ) ;
12871287 format ! ( "{}:{} {}" , source, line, msg)
12881288 } )
12891289 . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments