summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Henri Symoneaux <phsym@users.noreply.github.com>2018-12-17 16:07:53 +0100
committerGitHub <noreply@github.com>2018-12-17 16:07:53 +0100
commitfa70ca6fdb7d0d98a04961c1a74105e4f797661d (patch)
tree7d60a3ac47981c1ffe70f2eb53b993f50b4cc25c
parent835bdce85699b5031640aa7ad72c5beeccd7beb7 (diff)
parent43a3cdcee50dd13c49daf57badb85709d85287f6 (diff)
Merge pull request #95 from xanonid/code_style_improvements
Improve code style (suggestion by clippy)
-rw-r--r--src/cell.rs2
-rw-r--r--src/lib.rs3
-rw-r--r--src/row.rs2
3 files changed, 3 insertions, 4 deletions
diff --git a/src/cell.rs b/src/cell.rs
index bc25cec..f27b1bd 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -190,7 +190,7 @@ impl Cell {
/// Set horizontal span for this cell (must be > 0)
pub fn set_hspan(&mut self, hspan: usize) {
- self.hspan = if hspan <= 0 {1} else {hspan};
+ self.hspan = if hspan == 0 {1} else {hspan};
}
/// Get horizontal span of this cell (> 0)
diff --git a/src/lib.rs b/src/lib.rs
index 65f8b0c..0674793 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -15,7 +15,6 @@ use std::fmt;
use std::iter::{FromIterator, IntoIterator};
use std::slice::{Iter, IterMut};
use std::ops::{Index, IndexMut};
-use std::mem::transmute;
pub use term::{Attr, color};
pub(crate) use term::{Terminal, stdout};
@@ -502,7 +501,7 @@ impl<'a> AsRef<TableSlice<'a>> for Table {
// All this is a bit hacky. Let's try to find something else
let s = &mut *((self as *const Table) as *mut Table);
s.rows.shrink_to_fit();
- transmute(self)
+ &*(self as *const Table as *const TableSlice<'a>)
}
}
}
diff --git a/src/row.rs b/src/row.rs
index 856a8e0..5f34a24 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -66,7 +66,7 @@ impl Row {
pub fn get_column_width(&self, column: usize, format: &TableFormat) -> usize {
let mut i = 0;
for c in &self.cells {
- if i + c.get_hspan()-1 >= column {
+ if i + c.get_hspan() > column {
if c.get_hspan() == 1 {
return c.get_width();
}