rust_toolchain/
component.rs1use std::borrow::Cow;
2
3#[derive(Clone, Debug, Hash, Eq, PartialEq)]
12pub struct Component {
13 name: Cow<'static, str>,
14}
15
16impl Component {
17 pub fn new(name: impl Into<Cow<'static, str>>) -> Self {
19 Self { name: name.into() }
20 }
21
22 pub fn name(&self) -> &str {
24 self.name.as_ref()
25 }
26}
27
28#[cfg(test)]
29mod tests {
30 use super::*;
31
32 #[test]
33 fn new_instance() {
34 let c = Component::new("sample");
35 assert_eq!(c.name(), "sample");
36 }
37}