• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mattwparas / steel / 18461079395

13 Oct 2025 09:20AM UTC coverage: 42.731% (-0.9%) from 43.668%
18461079395

Pull #536

github

web-flow
Merge 6f55a8b56 into e378cba22
Pull Request #536: Initial proposal for no_std support

63 of 755 new or added lines in 38 files covered. (8.34%)

73 existing lines in 15 files now uncovered.

12324 of 28841 relevant lines covered (42.73%)

3215759.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/crates/steel-parser/src/pretty.rs
1
use alloc::string::String;
2
use alloc::vec::Vec;
3
use core::{fmt, marker::PhantomData};
4

5
pub struct RcDoc<'a, A> {
6
    buffer: String,
7
    _marker: PhantomData<&'a A>,
8
}
9

10
impl<'a, A> Clone for RcDoc<'a, A> {
NEW
11
    fn clone(&self) -> Self {
×
12
        Self {
NEW
13
            buffer: self.buffer.clone(),
×
14
            _marker: PhantomData,
15
        }
16
    }
17
}
18

19
impl<'a, A> fmt::Debug for RcDoc<'a, A> {
NEW
20
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
NEW
21
        f.debug_struct("RcDoc")
×
NEW
22
            .field("buffer", &self.buffer)
×
23
            .finish()
24
    }
25
}
26

27
impl<'a, A> RcDoc<'a, A> {
NEW
28
    pub fn text<T: Into<String>>(text: T) -> Self {
×
29
        Self {
NEW
30
            buffer: text.into(),
×
31
            _marker: PhantomData,
32
        }
33
    }
34

NEW
35
    pub fn space() -> Self {
×
NEW
36
        Self::text(" ")
×
37
    }
38

NEW
39
    pub fn line() -> Self {
×
NEW
40
        Self::text("\n")
×
41
    }
42

NEW
43
    pub fn append(mut self, other: RcDoc<'a, A>) -> Self {
×
NEW
44
        self.buffer.push_str(&other.buffer);
×
NEW
45
        self
×
46
    }
47

NEW
48
    pub fn nest(self, _indent: usize) -> Self {
×
NEW
49
        self
×
50
    }
51

NEW
52
    pub fn group(self) -> Self {
×
NEW
53
        self
×
54
    }
55

56
    pub fn intersperse<I>(iter: I, sep: RcDoc<'a, A>) -> RcDoc<'a, A>
57
    where
58
        I: IntoIterator<Item = RcDoc<'a, A>>,
59
    {
NEW
60
        let mut iter = iter.into_iter();
×
NEW
61
        let mut doc = if let Some(first) = iter.next() {
×
NEW
62
            first
×
63
        } else {
NEW
64
            return RcDoc::text("");
×
65
        };
66

NEW
67
        for item in iter {
×
NEW
68
            doc = doc.append(sep.clone()).append(item);
×
69
        }
70

NEW
71
        doc
×
72
    }
73

NEW
74
    pub fn to_string(&self) -> String {
×
NEW
75
        self.buffer.clone()
×
76
    }
77

NEW
78
    pub fn into_string(self) -> String {
×
NEW
79
        self.buffer
×
80
    }
81
}
82

83
impl<'a, A> RcDoc<'a, A> {
NEW
84
    pub fn render(&self, _width: usize, out: &mut Vec<u8>) -> Result<(), ()> {
×
NEW
85
        out.extend_from_slice(self.buffer.as_bytes());
×
NEW
86
        Ok(())
×
87
    }
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc