object_rainbow/impls/
cstring.rs

1use std::ffi::CString;
2
3use crate::*;
4
5impl ToOutput for CString {
6    fn to_output(&self, output: &mut dyn Output) {
7        self.as_c_str().to_output(output);
8    }
9}
10
11impl Topological for CString {}
12impl Tagged for CString {}
13
14impl<I: ParseInput> Parse<I> for CString {
15    fn parse(input: I) -> crate::Result<Self> {
16        Self::parse_as_inline(input)
17    }
18}
19
20impl<I: ParseInput> ParseInline<I> for CString {
21    fn parse_inline(input: &mut I) -> crate::Result<Self> {
22        let mut vec = Vec::new();
23        while let x = input.parse_inline()?
24            && x != 0
25        {
26            vec.push(x);
27        }
28        Ok(Self::new(vec).expect("should stop on zero"))
29    }
30}
31
32impl<E: 'static> Object<E> for CString {}
33impl<E: 'static> Inline<E> for CString {}
34impl ReflessObject for CString {}
35impl ReflessInline for CString {}
36
37impl MaybeHasNiche for CString {
38    type MnArray = NoNiche<NicheForUnsized>;
39}