Debian Codegraph @

src/writer.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::BufWriterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufwriter/BufWriter#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::LineWriterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/linewriter/LineWriter#;
3 #[cfg(any(doc, not(feature = "specialization")))]
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Stderrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/Stderr#;
5 #[cfg(any(doc, not(feature = "specialization")))]
6 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::StderrLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/StderrLock#;
7 #[cfg(any(doc, not(feature = "specialization")))]
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/Stdout#;
9 #[cfg(any(doc, not(feature = "specialization")))]
10 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::StdoutLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/StdoutLock#;
11 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#;
12 #[cfg(all(feature = "specialization", windows))]
13 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::windows::io::AsHandle;
14
15 #[cfg(windows)]
16 use superrust-analyzer cargo print_bytes 1.2.0 crate/::console::Console;
17
18 pub(superrust-analyzer cargo print_bytes 1.2.0 crate/) trait ToConsolerust-analyzer cargo print_bytes 1.2.0 writer/ToConsole# {
19 #[cfg(windows)]
20 fn to_console(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Console<'_>>;
21 }
22
23 #[cfg(feature = "specialization")]
24 impl<T> ToConsolerust-analyzer cargo print_bytes 1.2.0 writer/ToConsole# for T
25 where
26 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
27 {
28 #[cfg(windows)]
29 default fn to_console(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Console<'_>> {
30 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
31 }
32 }
33
34 #[cfg(all(feature = "specialization", windows))]
35 impl<T> ToConsolerust-analyzer cargo print_bytes 1.2.0 writer/ToConsole# for T
36 where
37 T: AsHandle + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#,
38 {
39 fn to_console(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Console<'_>> {
40 Console::from_handle(selfrust-analyzer cargo print_bytes 1.2.0 writer/)
41 }
42 }
43
44 /// A bound for [`write_lossy`] that allows it to be used for some types
45 /// without specialization.
46 ///
47 /// When the "specialization" feature is enabled, this trait is implemented for
48 /// all types.
49 ///
50 /// [`write_lossy`]: super::write_lossy
51 pub trait WriteLossyrust-analyzer cargo print_bytes 1.2.0 writer/WriteLossy# {
52 #[cfg(windows)]
53 #[doc(hidden)]
54 fn __to_console(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Console<'_>>;
55 }
56
57 #[cfg(feature = "specialization")]
58 #[cfg_attr(print_bytes_docs_rs, doc(cfg(feature = "specialization")))]
59 impl<T> WriteLossyrust-analyzer cargo print_bytes 1.2.0 writer/WriteLossy# for T
60 where
61 T: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
62 {
63 #[cfg(windows)]
64 default fn __to_console(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Console<'_>> {
65 selfrust-analyzer cargo print_bytes 1.2.0 writer/.to_console()
66 }
67 }
68
69 macro_rules! r#implrust-analyzer cargo print_bytes 1.2.0 writer/`r#impl`! {
70 ( $generic:ident , $type:ty ) => {
71 impl<$generic> WriteLossy for $type
72 where
73 $generic: ?Sized + WriteLossy,
74 {
75 #[cfg(windows)]
76 fn __to_console(&self) -> Option<Console<'_>> {
77 (**self).__to_console()
78 }
79 }
80 };
81 }
82 r#implrust-analyzer cargo print_bytes 1.2.0 writer/`r#impl`!!(T, &mut T);
83 r#implrust-analyzer cargo print_bytes 1.2.0 writer/`r#impl`!!(T, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<T>);
84
85 macro_rules! r#implrust-analyzer cargo print_bytes 1.2.0 writer/`r#impl`! {
86 ( $generic:ident , $type:ty ) => {
87 impl<$generic> WriteLossy for $type
88 where
89 $generic: Write + WriteLossy,
90 {
91 #[cfg(windows)]
92 fn __to_console(&self) -> Option<Console<'_>> {
93 self.get_ref().__to_console()
94 }
95 }
96 };
97 }
98 r#implrust-analyzer cargo print_bytes 1.2.0 writer/`r#impl`!!(T, BufWriterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufwriter/BufWriter#<T>);
99 r#implrust-analyzer cargo print_bytes 1.2.0 writer/`r#impl`!!(T, LineWriterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/linewriter/LineWriter#<T>);
100
101 macro_rules! impl_to_consolerust-analyzer cargo print_bytes 1.2.0 writer/impl_to_console! {
102 ( $(#[ $attr:meta ])* $type:ty , $to_console_fn:expr , ) => {
103 #[cfg(any(doc, not(feature = "specialization")))]
104 impl $crate::WriteLossy for $type {
105 #[cfg(windows)]
106 fn __to_console(&self) -> Option<Console<'_>> {
107 $crate::writer::ToConsole::to_console(self)
108 }
109 }
110
111 $(#[$attr])*
112 impl $crate::writer::ToConsole for $type {
113 #[cfg(windows)]
114 fn to_console<'a>(&'a self) -> Option<Console<'a>> {
115 let to_console_fn: fn(&'a Self) -> _ = $to_console_fn;
116 to_console_fn(self)
117 }
118 }
119 };
120 }
121
122 macro_rules! r#implrust-analyzer cargo print_bytes 1.2.0 writer/`r#impl`! {
123 ( $($type:ty),+ ) => {
124 $(impl_to_console! {
125 #[cfg(not(feature = "specialization"))]
126 $type, Console::from_handle,
127 })+
128 };
129 }
130 r#implrust-analyzer cargo print_bytes 1.2.0 writer/`r#impl`!!(Stderr, StderrLock<'_>, Stdout, StdoutLock<'_>);
131
132 impl_to_consolerust-analyzer cargo print_bytes 1.2.0 writer/impl_to_console!! {
133 #[cfg(not(feature = "specialization"))]
134 Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |_| Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
135 }