Function magnus::block::block_given
source · pub fn block_given() -> bool
Expand description
Returns whether a Ruby block has been supplied to the current method.
§Panics
Panics if called from a non-Ruby thread. See Ruby::block_given
for the
non-panicking version.
§Examples
use magnus::{block::block_given, define_global_function, function, rb_assert};
fn got_block() -> bool {
block_given()
}
define_global_function("got_block?", function!(got_block, 0));
rb_assert!("got_block? {} == true");
rb_assert!("got_block? == false");