`From<&CStr> for std::string_view`

Not particularly important, but it did look missing.

PiperOrigin-RevId: 588928572
Change-Id: Iaacd37121aa13fcfb16452c379339b1a021d7b54
diff --git a/support/cc_std/string_view.rs b/support/cc_std/string_view.rs
index f2efefb..084d47e 100644
--- a/support/cc_std/string_view.rs
+++ b/support/cc_std/string_view.rs
@@ -31,6 +31,12 @@
     }
 }
 
+impl From<&core::ffi::CStr> for string_view {
+    fn from(cstr: &core::ffi::CStr) -> Self {
+        string_view::from(cstr.to_bytes())
+    }
+}
+
 impl From<*const [u8]> for string_view {
     fn from(slice: *const [u8]) -> Self {
         // No stable way to do this per se, but the UCG documents this transmute is OK.
diff --git a/support/cc_std/test/string_view/test.rs b/support/cc_std/test/string_view/test.rs
index 6dfc881..4c36659 100644
--- a/support/cc_std/test/string_view/test.rs
+++ b/support/cc_std/test/string_view/test.rs
@@ -31,6 +31,15 @@
 }
 
 #[test]
+fn test_round_trip_cstr() {
+    let original: &'static str = "hello, world\0";
+    let cstr = core::ffi::CStr::from_bytes_with_nul(original.as_bytes()).unwrap();
+    let original = &original[..original.len() - 1]; // cut off nul for the comparison.
+    let sv: std::string_view = cstr.into();
+    assert_eq!(unsafe { to_str(sv) }, original);
+}
+
+#[test]
 fn test_ffi() {
     assert_eq!(unsafe { to_str(GetHelloWorld()) }, "Hello, world!");
 }