pub fn check_only_contains_regex(
    path: &str,
    template: &str,
    pkg_name: &str,
    pkg_version: &str
) -> Result<(), String>
Expand description

Check that path only contains matches to the regular expression given by template.

While the check_contains_regex function verifies the existance of at least one match, this function verifies that all matches use the correct version number. Use this if you have a file which should always reference the current version of your package.

The check proceeds in two steps:

  1. Replace {version} in template by a regular expression which will match any SemVer version number. This allows, say, "docs.rs/{name}/{version}/" to match old and outdated occurrences of your package.

  2. Find all matches in the file and check the version number in each match for compatibility with pkg_version. It is enough for the version number to be compatible, meaning that "foo/{version}/bar" matches “foo/1.2/bar”whenpkg_versionis“1.2.3”`.

It is an error if there are no matches for template at all.

The matching is done in multi-line mode, which means that ^ in the regular expression will match the beginning of any line in the file, not just the very beginning of the file.

Errors

If any of the matches are incompatible with pkg_version, an Err is returned with a succinct error message. Status information has then already been printed on stdout.