Debian Codegraph @

src/properties/color.rs

raw symbols SCIP
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::{Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#};
2 #[cfg(feature = "std")]
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::{Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#};
4
5 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
6 #[cfg_attr(feature = "serde", derive(serderust-analyzer cargo serde 1.0.203 crate/::Serializerust-analyzer cargo serde_derive 1.0.203 Serialize:, serderust-analyzer cargo serde 1.0.203 crate/::Deserializerust-analyzer cargo serde_derive 1.0.203 Deserialize:))]
7 /// A 24-bit color value stored as R, G, and B bytes
8 pub struct Colorrust-analyzer cargo mendeleev 0.8.1 properties/color/Color# {
9 /// Red component
10 pub rrust-analyzer cargo mendeleev 0.8.1 properties/color/Color#r.: u8,
11 /// Green component
12 pub grust-analyzer cargo mendeleev 0.8.1 properties/color/Color#g.: u8,
13 /// Blue component
14 pub brust-analyzer cargo mendeleev 0.8.1 properties/color/Color#b.: u8,
15 }
16
17 #[cfg(feature = "std")]
18 #[deprecated(since = "0.7.0", note = "Use color.to_string() instead")]
19 impl Colorrust-analyzer cargo mendeleev 0.8.1 properties/color/Color# {
20 /// Returns the html string for this color.
21 ///
22 /// ```
23 /// use mendeleev::{Element, Color};
24 ///
25 /// let color = Color{r: 0, g: 255, b: 255};
26 /// assert_eq!(color.html(), "#00ffff");
27 /// let color = Color{r: 48, g: 64, b: 80};
28 /// assert_eq!(color.html(), "#304050");
29 /// ```
30 pub fn htmlrust-analyzer cargo mendeleev 0.8.1 properties/color/impl#[Color]html().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
31 self.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
32 }
33 }
34
35 /// Displays the color as an HTML string.
36 ///
37 /// ```
38 /// use mendeleev::{Element, Color};
39 ///
40 /// let color = Color{r: 0, g: 255, b: 255};
41 /// assert_eq!(format!("{}", color), "#00ffff");
42 /// let color = Color{r: 48, g: 64, b: 80};
43 /// assert_eq!(format!("{}", color), "#304050");
44 /// ```
45 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Colorrust-analyzer cargo mendeleev 0.8.1 properties/color/Color# {
46 fn fmtrust-analyzer cargo mendeleev 0.8.1 properties/color/impl#[Color][Display]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
47 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "#{:02x}{:02x}{:02x}", self.rrust-analyzer cargo mendeleev 0.8.1 properties/color/Color#r., self.grust-analyzer cargo mendeleev 0.8.1 properties/color/Color#g., self.brust-analyzer cargo mendeleev 0.8.1 properties/color/Color#b.)
48 }
49 }
50
51 pub(craterust-analyzer cargo mendeleev 0.8.1 crate/) const fn colorrust-analyzer cargo mendeleev 0.8.1 properties/color/color().(r: u8, g: u8, b: u8) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Colorrust-analyzer cargo mendeleev 0.8.1 properties/color/Color#> {
52 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo mendeleev 0.8.1 properties/color/Color# { rrust-analyzer cargo mendeleev 0.8.1 properties/color/Color#r., grust-analyzer cargo mendeleev 0.8.1 properties/color/Color#g., brust-analyzer cargo mendeleev 0.8.1 properties/color/Color#b. })
53 }