flier / rust-hyperscan

Hyperscan bindings for Rust with Multiple Pattern and Streaming Scan
88 stars 28 forks source link

[Usage Help] the element type for this iterator is not specified #12

Closed JackLiar closed 3 years ago

JackLiar commented 4 years ago
fn test_chimera() {
        let regex = "(regex)";
        let patterns = Patterns::from_str(regex).unwrap();
        let db = patterns.build().unwrap();
        let mut scratch = db.alloc_scratch().unwrap();

        db.scan(
            "input with regex word",
            &mut scratch,
            |_id, _from, _to, _size, captured| {
                let captures = match captured {
                    None => todo!(),
                    Some(captures) => {
                        for cap in captures {
                            let a = cap.range();
                        }
                    }
                };

                Matching::Continue
            },
            |_err_type, _id| Matching::Continue,
        );
    }

The compiler says that she could not infer type for captures. While I think it's pretty clear captures is &[hyperscan::chimera::Capture]

JackLiar commented 3 years ago

Seems this is just a rust-analyzer issue, it is fixed now