Skip to content

Commit 869c85f

Browse files
committed
refactor: use cstr_to_string
1 parent 2d9183e commit 869c85f

File tree

1 file changed

+4
-2
lines changed
  • gems/codetracer-ruby-recorder/ext/native_tracer/src

1 file changed

+4
-2
lines changed

gems/codetracer-ruby-recorder/ext/native_tracer/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,10 @@ unsafe extern "C" fn initialize(self_val: VALUE, out_dir: VALUE, format: VALUE)
609609
let slice = std::slice::from_raw_parts(ptr, len);
610610

611611
let fmt = if !NIL_P(format) && RB_SYMBOL_P(format) {
612-
let id = rb_sym2id(format);
613-
match CStr::from_ptr(rb_id2name(id)).to_str().unwrap_or("") {
612+
match cstr_to_string(rb_id2name(rb_sym2id(format)))
613+
.unwrap_or_default()
614+
.as_str()
615+
{
614616
"binaryv0" => runtime_tracing::TraceEventsFileFormat::BinaryV0,
615617
"binary" | "bin" => runtime_tracing::TraceEventsFileFormat::Binary,
616618
"json" => runtime_tracing::TraceEventsFileFormat::Json,

0 commit comments

Comments
 (0)