Ad
  • Default User Avatar

    OK. Lot of thanks for your explanations and your work to fix that. I tried a solution without regex and it works!

  • Custom User Avatar

    @filosfino Can you try again? It should be fixed now.

    @g964
    I didn't realize this problem when a user can optionally use some crate and I don't think there's a way to completely fix it.
    The workaround was to bind to a different identifier.

    #[cfg(test)] extern crate regex as t_regex;
    #[cfg(test)]
    mod tests {
        use super::*;
        use t_regex::Regex;
    }
    

    You can also move extern crate inside mod tests and do use self::regex::Regex;. I don't know which one is better. If Rust users have opinions, please let me know.

    Another workaround might be to avoid use regex::Regex; and just do regex::Regex::new in the reference solution.

  • Custom User Avatar

    OK, I'll try and let you know.

  • Default User Avatar

    I am lost:-( Maybe it would be better if you fix it!

  • Custom User Avatar

    @g964 I think it validated because your solution contains the declaration.
    To use crates in test, do

    #[cfg(test)]
    extern crate regex; // <- outside of `mod tests`
    
    #[cfg(test)]
    mod tests {
    }
    

    I'll try fixing it if you want.

  • Custom User Avatar

    @filosfino

    See Rust wiki page for the list of crates.

    For self::, it's because Rust 1.15 is a huge hack on Codewars for historical reasons. It's fixed on 1.25/1.33. See List of Rust 1.15 kata to update. (this was caused by invalid test code)

  • Default User Avatar

    I will try again...
    Sorry for the inconvenience!

  • Default User Avatar

    Fixed, thanks!