Skip to content

Commit

Permalink
Remove to_str_unchecked() for issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
kenba committed Mar 19, 2021
1 parent fdbf953 commit 6c83ac3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
11 changes: 0 additions & 11 deletions src/info_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ impl InfoType {
CString::new(a)
}

pub unsafe fn to_str_unchecked(self) -> CString {
let mut a = self.to_vec_uchar();

// remove all trailing nulls if any
while let Some(0) = a.last() {
a.pop();
}

CString::from_vec_unchecked(a)
}

pub fn to_int(self) -> cl_int {
match self {
InfoType::Int(a) => a,
Expand Down
4 changes: 1 addition & 3 deletions src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 +690,9 @@ mod tests {
let value = value.to_str().unwrap();
println!("CL_PROGRAM_BUILD_OPTIONS: {:?}", value);

unsafe {
let value = get_program_build_info(program, device_id, ProgramBuildInfo::CL_PROGRAM_BUILD_LOG).unwrap();
let value = value.to_str_unchecked();
let value = value.to_str().unwrap();
println!("CL_PROGRAM_BUILD_LOG: {:?}", value);
}

let value = get_program_build_info(program, device_id, ProgramBuildInfo::CL_PROGRAM_BINARY_TYPE).unwrap();
let value = value.to_uint();
Expand Down

0 comments on commit 6c83ac3

Please sign in to comment.