This is an automated email from the ASF dual-hosted git repository. mssun pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git
commit adf9a4e4cdabbfb671cce1e1d272a533f6c1de36 Author: Mingshen Sun <[email protected]> AuthorDate: Sun Mar 22 13:26:51 2020 -0700 [rustfmt] Set use_field_init_shorthand to true --- .rustfmt.toml | 3 ++- common/rusty_leveldb_sgx/src/block.rs | 2 +- common/rusty_leveldb_sgx/src/block_builder.rs | 2 +- common/rusty_leveldb_sgx/src/blockhandle.rs | 5 +---- common/rusty_leveldb_sgx/src/db_impl.rs | 6 +++--- common/rusty_leveldb_sgx/src/db_iter.rs | 8 ++++---- common/rusty_leveldb_sgx/src/error.rs | 5 +---- common/rusty_leveldb_sgx/src/filter.rs | 5 +---- common/rusty_leveldb_sgx/src/key_types.rs | 2 +- common/rusty_leveldb_sgx/src/log.rs | 4 ++-- common/rusty_leveldb_sgx/src/merging_iter.rs | 4 ++-- common/rusty_leveldb_sgx/src/skipmap.rs | 4 ++-- common/rusty_leveldb_sgx/src/snapshot.rs | 2 +- common/rusty_leveldb_sgx/src/table_builder.rs | 4 ++-- common/rusty_leveldb_sgx/src/table_reader.rs | 10 +++++----- common/rusty_leveldb_sgx/src/version.rs | 6 +++--- common/rusty_leveldb_sgx/src/version_edit.rs | 16 +++++++--------- common/rusty_leveldb_sgx/src/version_set.rs | 6 +++--- 18 files changed, 42 insertions(+), 52 deletions(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index c51666e..80eeb40 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1 +1,2 @@ -edition = "2018" \ No newline at end of file +edition = "2018" +use_field_init_shorthand = true diff --git a/common/rusty_leveldb_sgx/src/block.rs b/common/rusty_leveldb_sgx/src/block.rs index 487cb60..0eca3a9 100644 --- a/common/rusty_leveldb_sgx/src/block.rs +++ b/common/rusty_leveldb_sgx/src/block.rs @@ -69,7 +69,7 @@ impl Block { assert!(contents.len() > 4); Block { block: Rc::new(contents), - opt: opt, + opt, } } } diff --git a/common/rusty_leveldb_sgx/src/block_builder.rs b/common/rusty_leveldb_sgx/src/block_builder.rs index ce0c686..cd00aee 100644 --- a/common/rusty_leveldb_sgx/src/block_builder.rs +++ b/common/rusty_leveldb_sgx/src/block_builder.rs @@ -28,7 +28,7 @@ impl BlockBuilder { BlockBuilder { buffer: Vec::with_capacity(o.block_size), opt: o, - restarts: restarts, + restarts, last_key: Vec::new(), restart_counter: 0, counter: 0, diff --git a/common/rusty_leveldb_sgx/src/blockhandle.rs b/common/rusty_leveldb_sgx/src/blockhandle.rs index 36fee2b..10b0152 100644 --- a/common/rusty_leveldb_sgx/src/blockhandle.rs +++ b/common/rusty_leveldb_sgx/src/blockhandle.rs @@ -27,10 +27,7 @@ impl BlockHandle { } pub fn new(offset: usize, size: usize) -> BlockHandle { - BlockHandle { - offset: offset, - size: size, - } + BlockHandle { offset, size } } pub fn offset(&self) -> usize { diff --git a/common/rusty_leveldb_sgx/src/db_impl.rs b/common/rusty_leveldb_sgx/src/db_impl.rs index 50ccc92..7a56758 100644 --- a/common/rusty_leveldb_sgx/src/db_impl.rs +++ b/common/rusty_leveldb_sgx/src/db_impl.rs @@ -84,7 +84,7 @@ impl DB { DB { name: name.to_owned(), - path: path, + path, lock: None, internal_cmp: Rc::new(Box::new(InternalKeyCmp(opt.cmp.clone()))), fpol: InternalFilterPolicy::new(opt.filter_policy.clone()), @@ -92,11 +92,11 @@ impl DB { mem: MemTable::new(opt.cmp.clone()), imm: None, - opt: opt, + opt, log: None, log_num: None, - cache: cache, + cache, vset: share(vset), snaps: SnapshotList::new(), diff --git a/common/rusty_leveldb_sgx/src/db_iter.rs b/common/rusty_leveldb_sgx/src/db_iter.rs index ff5b9ff..392a93b 100644 --- a/common/rusty_leveldb_sgx/src/db_iter.rs +++ b/common/rusty_leveldb_sgx/src/db_iter.rs @@ -45,10 +45,10 @@ impl DBIterator { ss: Snapshot, ) -> DBIterator { DBIterator { - cmp: cmp, - vset: vset, - iter: iter, - ss: ss, + cmp, + vset, + iter, + ss, dir: Direction::Forward, byte_count: random_period(), diff --git a/common/rusty_leveldb_sgx/src/error.rs b/common/rusty_leveldb_sgx/src/error.rs index 6a6fbb5..3f55bf9 100644 --- a/common/rusty_leveldb_sgx/src/error.rs +++ b/common/rusty_leveldb_sgx/src/error.rs @@ -68,10 +68,7 @@ impl Status { } else { err = format!("{:?}: {}", code, msg); } - return Status { - code: code, - err: err, - }; + return Status { code, err }; } } diff --git a/common/rusty_leveldb_sgx/src/filter.rs b/common/rusty_leveldb_sgx/src/filter.rs index a7c5371..1e276a2 100644 --- a/common/rusty_leveldb_sgx/src/filter.rs +++ b/common/rusty_leveldb_sgx/src/filter.rs @@ -82,10 +82,7 @@ impl BloomPolicy { k = 30; } - BloomPolicy { - bits_per_key: bits_per_key, - k: k, - } + BloomPolicy { bits_per_key, k } } fn bloom_hash(&self, data: &[u8]) -> u32 { diff --git a/common/rusty_leveldb_sgx/src/key_types.rs b/common/rusty_leveldb_sgx/src/key_types.rs index 00219f8..3e6481f 100644 --- a/common/rusty_leveldb_sgx/src/key_types.rs +++ b/common/rusty_leveldb_sgx/src/key_types.rs @@ -68,7 +68,7 @@ impl LookupKey { } LookupKey { - key: key, + key, key_offset: internal_keylen.required_space(), } } diff --git a/common/rusty_leveldb_sgx/src/log.rs b/common/rusty_leveldb_sgx/src/log.rs index 75eb554..9c5faa2 100644 --- a/common/rusty_leveldb_sgx/src/log.rs +++ b/common/rusty_leveldb_sgx/src/log.rs @@ -39,7 +39,7 @@ impl<W: Write> LogWriter<W> { dst: writer, current_block_offset: 0, block_size: BLOCK_SIZE, - digest: digest, + digest, } } @@ -131,7 +131,7 @@ pub struct LogReader<R: Read> { impl<R: Read> LogReader<R> { pub fn new(src: R, chksum: bool) -> LogReader<R> { LogReader { - src: src, + src, blk_off: 0, blocksize: BLOCK_SIZE, checksums: chksum, diff --git a/common/rusty_leveldb_sgx/src/merging_iter.rs b/common/rusty_leveldb_sgx/src/merging_iter.rs index af90393..6c20ba3 100644 --- a/common/rusty_leveldb_sgx/src/merging_iter.rs +++ b/common/rusty_leveldb_sgx/src/merging_iter.rs @@ -30,10 +30,10 @@ impl MergingIter { /// Construct a new merging iterator. pub fn new(cmp: Rc<Box<dyn Cmp>>, iters: Vec<Box<dyn LdbIterator>>) -> MergingIter { let mi = MergingIter { - iters: iters, + iters, current: None, direction: Direction::Forward, - cmp: cmp, + cmp, }; mi } diff --git a/common/rusty_leveldb_sgx/src/skipmap.rs b/common/rusty_leveldb_sgx/src/skipmap.rs index 34bc704..9976bd9 100644 --- a/common/rusty_leveldb_sgx/src/skipmap.rs +++ b/common/rusty_leveldb_sgx/src/skipmap.rs @@ -62,7 +62,7 @@ impl SkipMap { rand: StdRng::seed_from_u64(0xdeadbeef), len: 0, approx_mem: size_of::<Self>() + MAX_HEIGHT * size_of::<Option<*mut Node>>(), - cmp: cmp, + cmp, })), } } @@ -241,7 +241,7 @@ impl InnerSkipMap { let mut new = Box::new(Node { skips: new_skips, next: None, - key: key, + key, value: val, }); let newp = new.as_mut() as *mut Node; diff --git a/common/rusty_leveldb_sgx/src/snapshot.rs b/common/rusty_leveldb_sgx/src/snapshot.rs index 1577d57..395f714 100644 --- a/common/rusty_leveldb_sgx/src/snapshot.rs +++ b/common/rusty_leveldb_sgx/src/snapshot.rs @@ -69,7 +69,7 @@ impl SnapshotList { Snapshot { inner: Rc::new(InnerSnapshot { id: sl.newest, - seq: seq, + seq, sl: inner, }), } diff --git a/common/rusty_leveldb_sgx/src/table_builder.rs b/common/rusty_leveldb_sgx/src/table_builder.rs index 4313757..ebaf515 100644 --- a/common/rusty_leveldb_sgx/src/table_builder.rs +++ b/common/rusty_leveldb_sgx/src/table_builder.rs @@ -44,7 +44,7 @@ impl Footer { pub fn new(metaix: BlockHandle, index: BlockHandle) -> Footer { Footer { meta_index: metaix, - index: index, + index, } } @@ -120,7 +120,7 @@ impl<Dst: Write> TableBuilder<Dst> { pub fn new_raw(opt: Options, dst: Dst) -> TableBuilder<Dst> { TableBuilder { opt: opt.clone(), - dst: dst, + dst, offset: 0, prev_block_last_key: vec![], num_entries: 0, diff --git a/common/rusty_leveldb_sgx/src/table_reader.rs b/common/rusty_leveldb_sgx/src/table_reader.rs index 0e61819..cd87d87 100644 --- a/common/rusty_leveldb_sgx/src/table_reader.rs +++ b/common/rusty_leveldb_sgx/src/table_reader.rs @@ -54,13 +54,13 @@ impl Table { let cache_id = opt.block_cache.borrow_mut().new_cache_id(); Ok(Table { - file: file, + file, file_size: size, - cache_id: cache_id, - opt: opt, - footer: footer, + cache_id, + opt, + footer, filters: filter_block_reader, - indexblock: indexblock, + indexblock, }) } diff --git a/common/rusty_leveldb_sgx/src/version.rs b/common/rusty_leveldb_sgx/src/version.rs index 0564373..171890e 100644 --- a/common/rusty_leveldb_sgx/src/version.rs +++ b/common/rusty_leveldb_sgx/src/version.rs @@ -392,8 +392,8 @@ pub fn new_version_iter( ucmp: Rc<Box<dyn Cmp>>, ) -> VersionIter { VersionIter { - files: files, - cache: cache, + files, + cache, cmp: InternalKeyCmp(ucmp), current: None, current_ix: 0, @@ -596,7 +596,7 @@ pub mod testutil { share(FileMetaData { allowed_seeks: 10, size: 163840, - num: num, + num, smallest: LookupKey::new(smallest, smallestix).internal_key().to_vec(), largest: LookupKey::new(largest, largestix).internal_key().to_vec(), }) diff --git a/common/rusty_leveldb_sgx/src/version_edit.rs b/common/rusty_leveldb_sgx/src/version_edit.rs index fd6f159..860b2dc 100644 --- a/common/rusty_leveldb_sgx/src/version_edit.rs +++ b/common/rusty_leveldb_sgx/src/version_edit.rs @@ -121,7 +121,7 @@ impl VersionEdit { pub fn set_compact_pointer(&mut self, level: usize, key: InternalKey) { self.compaction_ptrs.push(CompactionPointer { - level: level, + level, key: Vec::from(key), }) } @@ -239,10 +239,8 @@ impl VersionEdit { if let Ok(lvl) = reader.read_varint() { let key = read_length_prefixed(&mut reader)?; - ve.compaction_ptrs.push(CompactionPointer { - level: lvl, - key: key, - }); + ve.compaction_ptrs + .push(CompactionPointer { level: lvl, key }); } else { return err(StatusCode::IOError, "Couldn't read level"); } @@ -269,10 +267,10 @@ impl VersionEdit { ve.new_files.push(( lvl, FileMetaData { - num: num, - size: size, - smallest: smallest, - largest: largest, + num, + size, + smallest, + largest, allowed_seeks: 0, }, )) diff --git a/common/rusty_leveldb_sgx/src/version_set.rs b/common/rusty_leveldb_sgx/src/version_set.rs index 6d61297..21976e0 100644 --- a/common/rusty_leveldb_sgx/src/version_set.rs +++ b/common/rusty_leveldb_sgx/src/version_set.rs @@ -47,7 +47,7 @@ impl Compaction { // Note: opt.cmp should be the user-supplied or default comparator (not an InternalKeyCmp). pub fn new(opt: &Options, level: usize, input: Option<Shared<Version>>) -> Compaction { Compaction { - level: level, + level, max_file_size: opt.max_file_size, input_version: input, level_ixs: Default::default(), @@ -195,8 +195,8 @@ impl VersionSet { VersionSet { dbname: db.as_ref().to_owned(), cmp: InternalKeyCmp(opt.cmp.clone()), - opt: opt, - cache: cache, + opt, + cache, next_file_num: 2, manifest_num: 0, --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
