Return a Result from constant_hash::probe.

When a hash table probe fails, return the index of the failed entry.
This can be used to store default values in the sentinel entries.
This commit is contained in:
Jakob Stoklund Olesen
2017-07-21 21:10:32 -07:00
parent 35cbe68a70
commit 4142a9ca9c
4 changed files with 38 additions and 22 deletions

View File

@@ -83,8 +83,8 @@ impl Builder {
/// Look up a descriptor by name.
fn lookup(&self, name: &str) -> Result<(usize, detail::Detail)> {
match probe(self.template, name, simple_hash(name)) {
None => Err(Error::BadName),
Some(entry) => {
Err(_) => Err(Error::BadName),
Ok(entry) => {
let d = &self.template.descriptors[self.template.hash_table[entry] as usize];
Ok((d.offset as usize, d.detail))
}