• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Utils for working with C strings, returning `anyhow::Result` on failure.
2 
3 use anyhow::{Context, Result};
4 use std::ffi::CString;
5 
6 /// Create a `CString` from a `&str`, returning an `anyhow::Result` on failure.
c_string(string: &str) -> Result<CString>7 pub fn c_string(string: &str) -> Result<CString> {
8     CString::new(string.as_bytes()).context("Failed to create CString")
9 }
10