INNER CODE UNIT · Rust

set_lossy

tensorflow/rust · src/lib.rs:497

    pub fn set_lossy(&mut self, code: Code, msg: &str) {
        let message = match CString::new(msg) {
            Ok(x) => x,
            Err(e) => {
                let pos = e.nul_position();
                let mut truncated_bytes = e.into_vec();
                truncated_bytes.truncate(pos);
                let mut new_msg: Vec<u8> = "(original error truncated due to internal nul byte) "
                    .as_bytes()
                    .into();
                new_msg.extend(&truncated_bytes);
                unsafe { CString::from_vec_unchecked(new_msg) }
            }
        };
        unsafe {
            tf::TF_SetStatus(self.inner, code.to_c(), message.as_ptr());
        }
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…