orphanage 0.5.6

Random collection of stuff that is still searching for a home.
Documentation
use std::{ffi::CString, path::Path};

/// Given a `Path`, return a `CString`, suitable for passing to C functions
/// that require null-terminated paths.
///
/// # Panics
/// Path must not include null's (which they shouldn't be able to).
#[must_use]
#[inline]
pub fn path_to_cstring(path: &Path) -> CString {
  let os_str = path.as_os_str();
  let bytes = os_str.as_encoded_bytes();

  // unwrap() should be okay because embeded null shouldn't be possible in a
  // Path.
  CString::new(bytes).unwrap()
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :