pub struct Brackets<'a>(&'a str);

impl<'a> From<&'a str> for Brackets<'a> {
    fn from(brackets: &'a str) -> Self {
        Brackets(brackets)
    }
}

impl<'a> Brackets<'a> {
    pub fn are_balanced(&self) -> bool {
        let mut stack = Vec::new();

        for c in self.0.chars() {
            match c {
                '[' | '{' | '(' => {
                    stack.push(c);
                },
                ']' | '}' | ')' => {
                    match stack.pop() {
                        Some(x) => {
                            if c == ']' && x != '[' ||
                               c == '}' && x != '{' ||
                               c == ')' && x != '(' {
                                return false
                            }
                        },
                        None => return false
                    }
                },
                _ => ()
            }
        }

        stack.len() == 0
    }
}

pub struct Brackets(String);

impl<'a> From<&'a str> for Brackets {
    fn from(string: &str) -> Self {
        Brackets(string.into())
    }
}

impl Brackets {
    pub fn are_balanced(&self) -> bool {
        let mut stack = Vec::new();

        for c in self.0.chars() {
            match c {
                '[' | '{' | '(' => {
                    stack.push(c);
                },
                ']' | '}' | ')' => {
                    match stack.pop() {
                        Some(x) => {
                            if c == ']' && x != '[' ||
                               c == '}' && x != '{' ||
                               c == ')' && x != '(' {
                                return false
                            }
                        },
                        None => return false
                    }
                },
                _ => ()
            }
        }

        stack.len() == 0
    }
}

--- 
+++ 
@@ -1,12 +1,12 @@
-pub struct Brackets(String);
+pub struct Brackets<'a>(&'a str);
 
-impl<'a> From<&'a str> for Brackets {
-    fn from(string: &str) -> Self {
-        Brackets(string.into())
+impl<'a> From<&'a str> for Brackets<'a> {
+    fn from(brackets: &'a str) -> Self {
+        Brackets(brackets)
     }
 }
 
-impl Brackets {
+impl<'a> Brackets<'a> {
     pub fn are_balanced(&self) -> bool {
         let mut stack = Vec::new();
 
Convert Bracket Push solution to store &str instead of String
