{"action":"created","comment":{"url":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/comments/178543019","pull_request_review_id":108614198,"id":178543019,"diff_hunk":"@@ -0,0 +1,69 @@\n+use difference;\n+\n+use Predicate;\n+\n+/// Predicate that diffs two strings.\n+///\n+/// This is created by the `predicate::str::diff`.\n+#[derive(Clone, Debug)]\n+pub struct DifferencePredicate {\n+    orig: String,\n+    split: String,\n+    distance: i32,\n+}\n+\n+impl DifferencePredicate {\n+    /// The split used when identifying changes.\n+    ///\n+    /// Common splits include:\n+    /// - `\"\"` for char-level.\n+    /// - `\" \"` for word-level.\n+    /// - `\"\\n\" for line-level.\n+    ///\n+    /// Default: `\"\\n\"`\n+    pub fn split<S>(mut self, split: S) -> Self\n+    where\n+        S: Into<String>,\n+    {\n+        self.split = split.into();\n+        self\n+    }\n+\n+    /// The maximum allowed edit distance.\n+    ///\n+    /// Default: `0`\n+    pub fn distance(mut self, distance: i32) -> Self {\n+        self.distance = distance;\n+        self\n+    }\n+}\n+\n+impl Predicate for DifferencePredicate {\n+    type Item = str;\n+\n+    fn eval(&self, edit: &str) -> bool {\n+        let change = difference::Changeset::new(&self.orig, edit, &self.split);\n+        change.distance <= self.distance\n+    }\n+}\n+\n+/// Creates a new `Predicate` that diffs two strings.\n+///\n+/// # Examples\n+///\n+/// ```\n+/// use predicates::predicate::*;\n+///\n+/// let predicate_fn = str::diff(\"Hello World\");\n+/// assert_eq!(true, predicate_fn.eval(\"Hello World\"));\n+/// ```\n+pub fn diff<S>(orig: S) -> DifferencePredicate","path":"src/predicate/str/difference.rs","position":60,"original_position":60,"commit_id":"afe93b0e7d4cf15ef202e6c6361e725a329bede7","original_commit_id":"afe93b0e7d4cf15ef202e6c6361e725a329bede7","user":{"login":"epage","id":60961,"avatar_url":"https://avatars2.githubusercontent.com/u/60961?v=4","gravatar_id":"","url":"https://api.github.com/users/epage","html_url":"https://github.com/epage","followers_url":"https://api.github.com/users/epage/followers","following_url":"https://api.github.com/users/epage/following{/other_user}","gists_url":"https://api.github.com/users/epage/gists{/gist_id}","starred_url":"https://api.github.com/users/epage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epage/subscriptions","organizations_url":"https://api.github.com/users/epage/orgs","repos_url":"https://api.github.com/users/epage/repos","events_url":"https://api.github.com/users/epage/events{/privacy}","received_events_url":"https://api.github.com/users/epage/received_events","type":"User","site_admin":false},"body":"While this has features for edit-distance, as a user, my real care about is showing the diff between the strings once #7 is available and I was going for a name that communicated that.\r\n\r\nI can see how the name implies the opposite meaning.  What if instead I reversed the behavior of `eval` instead?  The downside is that almost everyone will now need to `not` it.","created_at":"2018-04-02T13:25:21Z","updated_at":"2018-04-02T13:25:21Z","html_url":"https://github.com/assert-rs/predicates-rs/pull/18#discussion_r178543019","pull_request_url":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/18","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/comments/178543019"},"html":{"href":"https://github.com/assert-rs/predicates-rs/pull/18#discussion_r178543019"},"pull_request":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/18"}},"in_reply_to_id":178480926},"pull_request":{"url":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/18","id":178712900,"html_url":"https://github.com/assert-rs/predicates-rs/pull/18","diff_url":"https://github.com/assert-rs/predicates-rs/pull/18.diff","patch_url":"https://github.com/assert-rs/predicates-rs/pull/18.patch","issue_url":"https://api.github.com/repos/assert-rs/predicates-rs/issues/18","number":18,"state":"open","locked":false,"title":"Add specialized predicates","user":{"login":"epage","id":60961,"avatar_url":"https://avatars2.githubusercontent.com/u/60961?v=4","gravatar_id":"","url":"https://api.github.com/users/epage","html_url":"https://github.com/epage","followers_url":"https://api.github.com/users/epage/followers","following_url":"https://api.github.com/users/epage/following{/other_user}","gists_url":"https://api.github.com/users/epage/gists{/gist_id}","starred_url":"https://api.github.com/users/epage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epage/subscriptions","organizations_url":"https://api.github.com/users/epage/orgs","repos_url":"https://api.github.com/users/epage/repos","events_url":"https://api.github.com/users/epage/events{/privacy}","received_events_url":"https://api.github.com/users/epage/received_events","type":"User","site_admin":false},"body":"- All external crates are optional\r\n- Specialized functions are in a child module with a name for the type.\r\n  - Names would be verbose anyways\r\n  - This provides the user the opportunity to shorten it if they desire.\r\n\r\nParticular notes\r\n- Edit-distance is limited in use until #7 is implemented.  Its still nice to have now to help ensure #7 supports everything it needs\r\n- I'm a little mixed on the regex API.  I'm starting to think its sufficient as is but we should probably document it to clarify how to work around the constrained by straight forward API.","created_at":"2018-04-01T04:37:09Z","updated_at":"2018-04-02T13:25:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fe723f14ec9f6e41ff526744ab0321843d3a27cc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/18/commits","review_comments_url":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/18/comments","review_comment_url":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/assert-rs/predicates-rs/issues/18/comments","statuses_url":"https://api.github.com/repos/assert-rs/predicates-rs/statuses/afe93b0e7d4cf15ef202e6c6361e725a329bede7","head":{"label":"epage:pred","ref":"pred","sha":"afe93b0e7d4cf15ef202e6c6361e725a329bede7","user":{"login":"epage","id":60961,"avatar_url":"https://avatars2.githubusercontent.com/u/60961?v=4","gravatar_id":"","url":"https://api.github.com/users/epage","html_url":"https://github.com/epage","followers_url":"https://api.github.com/users/epage/followers","following_url":"https://api.github.com/users/epage/following{/other_user}","gists_url":"https://api.github.com/users/epage/gists{/gist_id}","starred_url":"https://api.github.com/users/epage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epage/subscriptions","organizations_url":"https://api.github.com/users/epage/orgs","repos_url":"https://api.github.com/users/epage/repos","events_url":"https://api.github.com/users/epage/events{/privacy}","received_events_url":"https://api.github.com/users/epage/received_events","type":"User","site_admin":false},"repo":{"id":127158015,"name":"predicates-rs","full_name":"epage/predicates-rs","owner":{"login":"epage","id":60961,"avatar_url":"https://avatars2.githubusercontent.com/u/60961?v=4","gravatar_id":"","url":"https://api.github.com/users/epage","html_url":"https://github.com/epage","followers_url":"https://api.github.com/users/epage/followers","following_url":"https://api.github.com/users/epage/following{/other_user}","gists_url":"https://api.github.com/users/epage/gists{/gist_id}","starred_url":"https://api.github.com/users/epage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epage/subscriptions","organizations_url":"https://api.github.com/users/epage/orgs","repos_url":"https://api.github.com/users/epage/repos","events_url":"https://api.github.com/users/epage/events{/privacy}","received_events_url":"https://api.github.com/users/epage/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/epage/predicates-rs","description":"An implementation of boolean-valued predicate functions in Rust","fork":true,"url":"https://api.github.com/repos/epage/predicates-rs","forks_url":"https://api.github.com/repos/epage/predicates-rs/forks","keys_url":"https://api.github.com/repos/epage/predicates-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/epage/predicates-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/epage/predicates-rs/teams","hooks_url":"https://api.github.com/repos/epage/predicates-rs/hooks","issue_events_url":"https://api.github.com/repos/epage/predicates-rs/issues/events{/number}","events_url":"https://api.github.com/repos/epage/predicates-rs/events","assignees_url":"https://api.github.com/repos/epage/predicates-rs/assignees{/user}","branches_url":"https://api.github.com/repos/epage/predicates-rs/branches{/branch}","tags_url":"https://api.github.com/repos/epage/predicates-rs/tags","blobs_url":"https://api.github.com/repos/epage/predicates-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/epage/predicates-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/epage/predicates-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/epage/predicates-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/epage/predicates-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/epage/predicates-rs/languages","stargazers_url":"https://api.github.com/repos/epage/predicates-rs/stargazers","contributors_url":"https://api.github.com/repos/epage/predicates-rs/contributors","subscribers_url":"https://api.github.com/repos/epage/predicates-rs/subscribers","subscription_url":"https://api.github.com/repos/epage/predicates-rs/subscription","commits_url":"https://api.github.com/repos/epage/predicates-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/epage/predicates-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/epage/predicates-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/epage/predicates-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/epage/predicates-rs/contents/{+path}","compare_url":"https://api.github.com/repos/epage/predicates-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/epage/predicates-rs/merges","archive_url":"https://api.github.com/repos/epage/predicates-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/epage/predicates-rs/downloads","issues_url":"https://api.github.com/repos/epage/predicates-rs/issues{/number}","pulls_url":"https://api.github.com/repos/epage/predicates-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/epage/predicates-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/epage/predicates-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/epage/predicates-rs/labels{/name}","releases_url":"https://api.github.com/repos/epage/predicates-rs/releases{/id}","deployments_url":"https://api.github.com/repos/epage/predicates-rs/deployments","created_at":"2018-03-28T15:06:41Z","updated_at":"2018-03-28T15:06:43Z","pushed_at":"2018-04-01T04:51:20Z","git_url":"git://github.com/epage/predicates-rs.git","ssh_url":"git@github.com:epage/predicates-rs.git","clone_url":"https://github.com/epage/predicates-rs.git","svn_url":"https://github.com/epage/predicates-rs","homepage":"https://docs.rs/predicates","size":39,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"assert-rs:master","ref":"master","sha":"d65bf5b0e44e62857338f2ee6872e65ce4b6d026","user":{"login":"assert-rs","id":36999732,"avatar_url":"https://avatars1.githubusercontent.com/u/36999732?v=4","gravatar_id":"","url":"https://api.github.com/users/assert-rs","html_url":"https://github.com/assert-rs","followers_url":"https://api.github.com/users/assert-rs/followers","following_url":"https://api.github.com/users/assert-rs/following{/other_user}","gists_url":"https://api.github.com/users/assert-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/assert-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/assert-rs/subscriptions","organizations_url":"https://api.github.com/users/assert-rs/orgs","repos_url":"https://api.github.com/users/assert-rs/repos","events_url":"https://api.github.com/users/assert-rs/events{/privacy}","received_events_url":"https://api.github.com/users/assert-rs/received_events","type":"Organization","site_admin":false},"repo":{"id":92963507,"name":"predicates-rs","full_name":"assert-rs/predicates-rs","owner":{"login":"assert-rs","id":36999732,"avatar_url":"https://avatars1.githubusercontent.com/u/36999732?v=4","gravatar_id":"","url":"https://api.github.com/users/assert-rs","html_url":"https://github.com/assert-rs","followers_url":"https://api.github.com/users/assert-rs/followers","following_url":"https://api.github.com/users/assert-rs/following{/other_user}","gists_url":"https://api.github.com/users/assert-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/assert-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/assert-rs/subscriptions","organizations_url":"https://api.github.com/users/assert-rs/orgs","repos_url":"https://api.github.com/users/assert-rs/repos","events_url":"https://api.github.com/users/assert-rs/events{/privacy}","received_events_url":"https://api.github.com/users/assert-rs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/assert-rs/predicates-rs","description":"An implementation of boolean-valued predicate functions in Rust","fork":false,"url":"https://api.github.com/repos/assert-rs/predicates-rs","forks_url":"https://api.github.com/repos/assert-rs/predicates-rs/forks","keys_url":"https://api.github.com/repos/assert-rs/predicates-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/assert-rs/predicates-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/assert-rs/predicates-rs/teams","hooks_url":"https://api.github.com/repos/assert-rs/predicates-rs/hooks","issue_events_url":"https://api.github.com/repos/assert-rs/predicates-rs/issues/events{/number}","events_url":"https://api.github.com/repos/assert-rs/predicates-rs/events","assignees_url":"https://api.github.com/repos/assert-rs/predicates-rs/assignees{/user}","branches_url":"https://api.github.com/repos/assert-rs/predicates-rs/branches{/branch}","tags_url":"https://api.github.com/repos/assert-rs/predicates-rs/tags","blobs_url":"https://api.github.com/repos/assert-rs/predicates-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/assert-rs/predicates-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/assert-rs/predicates-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/assert-rs/predicates-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/assert-rs/predicates-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/assert-rs/predicates-rs/languages","stargazers_url":"https://api.github.com/repos/assert-rs/predicates-rs/stargazers","contributors_url":"https://api.github.com/repos/assert-rs/predicates-rs/contributors","subscribers_url":"https://api.github.com/repos/assert-rs/predicates-rs/subscribers","subscription_url":"https://api.github.com/repos/assert-rs/predicates-rs/subscription","commits_url":"https://api.github.com/repos/assert-rs/predicates-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/assert-rs/predicates-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/assert-rs/predicates-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/assert-rs/predicates-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/assert-rs/predicates-rs/contents/{+path}","compare_url":"https://api.github.com/repos/assert-rs/predicates-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/assert-rs/predicates-rs/merges","archive_url":"https://api.github.com/repos/assert-rs/predicates-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/assert-rs/predicates-rs/downloads","issues_url":"https://api.github.com/repos/assert-rs/predicates-rs/issues{/number}","pulls_url":"https://api.github.com/repos/assert-rs/predicates-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/assert-rs/predicates-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/assert-rs/predicates-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/assert-rs/predicates-rs/labels{/name}","releases_url":"https://api.github.com/repos/assert-rs/predicates-rs/releases{/id}","deployments_url":"https://api.github.com/repos/assert-rs/predicates-rs/deployments","created_at":"2017-05-31T15:56:37Z","updated_at":"2018-03-29T03:45:40Z","pushed_at":"2018-04-01T04:51:21Z","git_url":"git://github.com/assert-rs/predicates-rs.git","ssh_url":"git@github.com:assert-rs/predicates-rs.git","clone_url":"https://github.com/assert-rs/predicates-rs.git","svn_url":"https://github.com/assert-rs/predicates-rs","homepage":"https://docs.rs/predicates","size":30,"stargazers_count":2,"watchers_count":2,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2,"open_issues":11,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/18"},"html":{"href":"https://github.com/assert-rs/predicates-rs/pull/18"},"issue":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/issues/18"},"comments":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/assert-rs/predicates-rs/statuses/afe93b0e7d4cf15ef202e6c6361e725a329bede7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"epage"}}