Solving MAXSAT and saying a few words about it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

#### 74 lines 1.2 KiB Raw Permalink Blame History

 `// vim: ts=4 sw=4 et` `use core::hash::{Hash, Hasher};` `use core::ops::{Deref, DerefMut};` `// A type for manipulating how something is hashed.` `pub struct HashWrapper(T, F)` `where` ` F: Fn(&T) -> U,` ` U: Hash;` `impl HashWrapper` `where` ` F: Fn(&T) -> U,` ` U: Hash,` `{` ` pub fn new(item: T, map: F) -> HashWrapper {` ` HashWrapper(item, map)` ` }` ` pub fn into_innner(self) -> T {` ` self.0` ` }` `}` `impl PartialEq for HashWrapper` `where` ` F: Fn(&T) -> U,` ` U: Hash + Eq,` `{` ` fn eq(&self, other: &Self) -> bool {` ` self.1(&self.0).eq(&other.1(&other.0))` ` }` `}` `impl Eq for HashWrapper` `where` ` F: Fn(&T) -> U,` ` U: Hash + Eq,` `{` `}` `impl Hash for HashWrapper` `where` ` F: Fn(&T) -> U,` ` U: Hash,` `{` ` fn hash(&self, state: &mut H) {` ` self.1(&self.0).hash(state);` ` }` `}` `impl Deref for HashWrapper` `where` ` F: Fn(&T) -> U,` ` U: Hash,` `{` ` type Target = T;` ` fn deref(&self) -> &T {` ` &self.0` ` }` `}` `impl DerefMut for HashWrapper` `where` ` F: Fn(&T) -> U,` ` U: Hash,` `{` ` fn deref_mut(&mut self) -> &mut T {` ` &mut self.0` ` }` ```} ```