Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e03110

Browse files
committed
feat: decode::Options::default_from_object_hash()
An easier way to initialize decode options, providing only the mandatory information.
1 parent 6fb3255 commit 9e03110

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

git-index/src/decode/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ pub struct Options {
4545
pub min_extension_block_in_bytes_for_threading: usize,
4646
}
4747

48+
impl Options {
49+
/// Produce a reasonable default set of options knowing only the kind of object hash to expect.
50+
pub fn default_from_object_hash(object_hash: git_hash::Kind) -> Self {
51+
Options {
52+
object_hash,
53+
thread_limit: None,
54+
min_extension_block_in_bytes_for_threading: 0,
55+
}
56+
}
57+
}
58+
4859
impl State {
4960
/// Decode an index state from `data` and store `timestamp` in the resulting instance for pass-through.
5061
pub fn from_bytes(

git-index/tests/index/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ fn size_of_entry() {
2323
}
2424

2525
pub fn decode_options() -> git_index::decode::Options {
26-
git_index::decode::Options {
27-
object_hash: git_hash::Kind::Sha1,
28-
thread_limit: None,
29-
min_extension_block_in_bytes_for_threading: 0,
30-
}
26+
git_index::decode::Options::default_from_object_hash(git_hash::Kind::Sha1)
3127
}
3228

3329
enum Fixture {

0 commit comments

Comments
 (0)