comparison rust/hg-core/src/filepatterns.rs @ 42609:326fdce22fb2

rust: switch hg-core and hg-cpython to rust 2018 edition Many interesting changes have happened in Rust since the Oxidation Plan was introduced, like the 2018 edition and procedural macros: - Opting in to the 2018 edition is a clear benefit in terms of future proofing, new (nice to have) syntactical sugar notwithstanding. It also has a new non-lexical, non-AST based borrow checker that has fewer bugs(!) and allows us to write correct code that in some cases would have been rejected by the old one. - Procedural macros allow us to use the PyO3 crate which maintainers have expressed the clear goal of compiling on stable, which would help in code maintainability compared to rust-cpython. In this patch are the following changes: - Removing most `extern crate` uses - Updating `use` clauses (`crate` keyword, nested `use`) - Removing `mod.rs` in favor of an aptly named module file Like discussed in the mailing list ( https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-July/132316.html ), until Rust integration in Mercurial is considered to be out of the experimental phase, the maximum version of Rust allowed is whatever the latest version Debian packages. Differential Revision: https://phab.mercurial-scm.org/D6597
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 02 Jul 2019 17:15:03 +0200
parents a4a468b00d44
children 0247601869ba
comparison
equal deleted inserted replaced
42608:717686c5e461 42609:326fdce22fb2
1 use crate::{LineNumber, PatternError, PatternFileError}; 1 use crate::{
2 utils::{files::get_path_from_bytes, replace_slice, SliceExt},
3 LineNumber, PatternError, PatternFileError,
4 };
5 use lazy_static::lazy_static;
2 use regex::bytes::Regex; 6 use regex::bytes::Regex;
3 use std::collections::HashMap; 7 use std::collections::HashMap;
4 use std::fs::File; 8 use std::fs::File;
5 use std::io::Read; 9 use std::io::Read;
6 use std::vec::Vec; 10 use std::vec::Vec;
7 use utils::files::get_path_from_bytes;
8 use utils::{replace_slice, SliceExt};
9 11
10 lazy_static! { 12 lazy_static! {
11 static ref RE_ESCAPE: Vec<Vec<u8>> = { 13 static ref RE_ESCAPE: Vec<Vec<u8>> = {
12 let mut v: Vec<Vec<u8>> = (0..=255).map(|byte| vec![byte]).collect(); 14 let mut v: Vec<Vec<u8>> = (0..=255).map(|byte| vec![byte]).collect();
13 let to_escape = b"()[]{}?*+-|^$\\.&~# \t\n\r\x0b\x0c"; 15 let to_escape = b"()[]{}?*+-|^$\\.&~# \t\n\r\x0b\x0c";