Repository: tomekpiotrowski/lets_expect (rust)

Issue:
Handle `Expr::Index` in `expr_to_ident`

Pull request description:
Handle `Expr::Index` in `expr_to_ident`
Fixes #81

Patch:
diff --git a/lets_expect_core/src/utils/to_ident.rs b/lets_expect_core/src/utils/to_ident.rs
index 70ee614..255f995 100644
--- a/lets_expect_core/src/utils/to_ident.rs
+++ b/lets_expect_core/src/utils/to_ident.rs
@@ -83,7 +83,11 @@ pub fn expr_to_ident(expr: &syn::Expr) -> String {
         Expr::ForLoop(_) => unimplemented!("ForLoop not supported"),
         Expr::Group(_) => unimplemented!("Group not supported"),
         Expr::If(if_expr) => "if_".to_string() + &expr_to_ident(&if_expr.cond),
-        Expr::Index(_) => unimplemented!("Index not supported"),
+        Expr::Index(index) => format!(
+            "{}_at_{}",
+            expr_to_ident(&index.expr),
+            expr_to_ident(&index.index)
+        ),
         Expr::Let(_) => unimplemented!("Let not supported"),
         Expr::Lit(lit) => expr_lit_to_ident(lit),
         Expr::Loop(_) => unimplemented!("Loop not supported"),


Test patch:
diff --git a/tests/array.rs b/tests/array.rs
index 72a435e..be6f955 100644
--- a/tests/array.rs
+++ b/tests/array.rs
@@ -2,6 +2,10 @@
 mod tests {
     use lets_expect::lets_expect;
 
+    struct Array<T> {
+        data: [T; 3],
+    }
+
     lets_expect! {
         expect([] as [u8; 0]) {
             to have(len()) equal(0)
@@ -15,5 +19,9 @@ mod tests {
             to have(mut iter()) all(be_greater_than(0))
             to have(mut iter()) any(be_less_or_equal_to(1))
         }
+
+        expect(Array { data: [1, 2, 3] }) {
+            to have(data[0]) equal(1)
+        }
     }
 }