[all] Apply cargo fmt, and fix clippy warning of branches_sharing_code

This commit is contained in:
Ming-Hung Tsai 2021-07-01 20:14:58 +08:00
parent 5ac9ae2dae
commit 1526ab3472
4 changed files with 27 additions and 43 deletions

View File

@ -183,8 +183,7 @@ impl<'a> StatefulWidget for SBWidget<'a> {
format!("{}k", sb.data_block_size * 2),
];
let table = Table::new(
vec![
let table = Table::new(vec![
Row::new(flags),
Row::new(block),
Row::new(uuid),
@ -195,12 +194,8 @@ impl<'a> StatefulWidget for SBWidget<'a> {
Row::new(mapping_root),
Row::new(details_root),
Row::new(data_block_size),
]
)
.header(
Row::new(vec!["Field", "Value"])
.style(Style::default().fg(Color::Yellow))
)
])
.header(Row::new(vec!["Field", "Value"]).style(Style::default().fg(Color::Yellow)))
.block(
Block::default()
.borders(Borders::ALL)
@ -251,19 +246,14 @@ impl<'a> Widget for HeaderWidget<'a> {
let max_entries = vec!["max_entries".to_string(), format!("{}", hdr.max_entries)];
let value_size = vec!["value size".to_string(), format!("{}", hdr.value_size)];
let table = Table::new(
vec![
let table = Table::new(vec![
Row::new(block),
Row::new(kind),
Row::new(nr_entries),
Row::new(max_entries),
Row::new(value_size),
]
)
.header(
Row::new(vec!["Field", "Value"])
.style(Style::default().fg(Color::Yellow))
)
])
.header(Row::new(vec!["Field", "Value"]).style(Style::default().fg(Color::Yellow)))
.block(Block::default().borders(Borders::ALL).title(self.title))
.widths(&[Constraint::Length(20), Constraint::Length(60)])
.style(Style::default().fg(Color::White))

View File

@ -258,8 +258,7 @@ impl AsyncIoEngine {
let fd_inner = inner.input.as_raw_fd();
for (i, b) in blocks.iter().enumerate() {
let read_e = opcode::Read::new(
types::Fd(fd_inner), b.data, BLOCK_SIZE as u32)
let read_e = opcode::Read::new(types::Fd(fd_inner), b.data, BLOCK_SIZE as u32)
.offset(b.loc as i64 * BLOCK_SIZE as i64);
unsafe {
@ -310,8 +309,7 @@ impl AsyncIoEngine {
let fd_inner = inner.input.as_raw_fd();
for (i, b) in blocks.iter().enumerate() {
let write_e = opcode::Write::new(
types::Fd(fd_inner), b.data, BLOCK_SIZE as u32)
let write_e = opcode::Write::new(types::Fd(fd_inner), b.data, BLOCK_SIZE as u32)
.offset(b.loc as i64 * BLOCK_SIZE as i64);
unsafe {

View File

@ -59,11 +59,11 @@ fn summarise_node(data: &[u8]) -> IResult<&[u8], NodeSummary> {
pub fn pack_btree_node<W: Write>(w: &mut W, data: &[u8]) -> PResult<()> {
let (_, info) = nom_to_pr(summarise_node(data))?;
let (i, hdr) = nom_to_pr(take(32usize)(data))?;
let (i, keys) = nom_to_pr(run64(i, info.max_entries))?;
if info.is_leaf {
if info.value_size == std::mem::size_of::<u64>() {
let (i, hdr) = nom_to_pr(take(32usize)(data))?;
let (i, keys) = nom_to_pr(run64(i, info.max_entries))?;
let (tail, values) = nom_to_pr(run64(i, info.max_entries))?;
io_to_pr(pack_literal(w, hdr))?;
@ -76,8 +76,7 @@ pub fn pack_btree_node<W: Write>(w: &mut W, data: &[u8]) -> PResult<()> {
Ok(())
} else {
// We don't bother packing the values if they aren't u64
let (i, hdr) = nom_to_pr(take(32usize)(data))?;
let (tail, keys) = nom_to_pr(run64(i, info.max_entries))?;
let tail = i;
io_to_pr(pack_literal(w, hdr))?;
io_to_pr(pack_u64s(w, &keys))?;
@ -87,8 +86,6 @@ pub fn pack_btree_node<W: Write>(w: &mut W, data: &[u8]) -> PResult<()> {
}
} else {
// Internal node, values are also u64s
let (i, hdr) = nom_to_pr(take(32usize)(data))?;
let (i, keys) = nom_to_pr(run64(i, info.max_entries))?;
let (tail, values) = nom_to_pr(run64(i, info.max_entries))?;
io_to_pr(pack_literal(w, hdr))?;

View File

@ -210,14 +210,13 @@ impl<'a> LeafWalker<'a> {
let depth = self.get_depth::<V>(path, root, true)?;
self.sm_inc(root);
if depth == 0 {
// root is a leaf
self.sm_inc(root);
self.leaves.insert(root as usize);
visitor.visit(&kr, root)?;
Ok(())
} else {
self.sm_inc(root);
let root = self.engine.read(root).map_err(|_| io_err(path))?;
self.walk_node(depth - 1, path, visitor, &kr, &root, true)