Skip to content

Commit eaff73d

Browse files
committed
Merge pull request #18 from phsym/ascription_fix
Ascription fix
2 parents b770f25 + 73298cc commit eaff73d

File tree

7 files changed

+32
-33
lines changed

7 files changed

+32
-33
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
language: rust
22
rust:
3-
- stable
4-
- beta
5-
- nightly
6-
matrix:
7-
allow_failures:
8-
- rust: nightly
3+
- stable
4+
- beta
5+
- nightly
6+
# matrix:
7+
# allow_failures:
8+
# - rust: nightly
99
env:
1010
global:
11-
- secure: M+X/Y/0FmtXj18pp2WI4KRyHx+C9B8ITxyfoIOY7sXu+zI06hmmWbawQSpKRzQY3KhTxXAXw7DMtsLlyHioz3w4iIoFykhai6DrUQWDocagPwvVA6hWf+mW7j3DiFlfx/0VT9JMi6Y0RyUcvo1e2snFKI9zQP20EOwK8IIyWUcwFks2Fpu1Hu3Bu8bw9lB3D6ZdzxbAuctcy+OuMR7OD6QFyHi8jQ2Q3yUruh3yLqy30bJSD3Nerw+PuwKiDX2tnObNUVRT0W0IQx6Yvk5sA7m+IZf2VM2ayKw6ChLdDC9yOa/s0mNzHBT7rE1HGfkYIsgc9kos2zZP5fMawDELpEDccPq19DYsno2gb7zFj7fyTFJbkqlROoj6cgL4xkBQAY/yRpnMzHhwLV1tu2lOJCdhyujCImb+mAZV14U7fkCAzYUrtxfdNImp88QQgynRC74vOAJc6qHnRI0ut6DoKcNqK+nn07spPY0wrAD4F+o7Nc32JcfJJ/YW7QvJBsWi6IdSduKvJyWTFtFLnLUzjsFT+C0U2P8dykOf1C4gxdUdUnxwSMDPC4+8VZlcqjPowjQ2xqS04TRKx45SEUDuX2xM0E2r8pIZpxNUm/NP1bwgumO0zMJCLEsIYe561BLODyOjmmsW2YVg2WOdpJWGh+Mbzr6aDu3B4FO4PbjZdEoI=
12-
- secure: uEDWqegkGvkCo9qE5h3j/VvD007MKjwfsX9+CiWKK+nd+FrfqUak/LpS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xfdNImp88QQgynRC74vOAJc6qHnRI0ut6DoKcNqK+nn07spPY0wrAD4F+o7Nc32JcfJJ/YW7QvJBsWi6IdSduKvJyWTFtFLnLUzjsFT+C0U2P8dykOf1C4gxdUdUnxwSMDPC4+8VZlcqjPowjQ2xqS04TRKx45SEUDuX2xM0E2r8pIZpxNUm/NP1bwgumO0zMJCLEsIYe561BLODyOjmmsW2YVg2WOdpJWGh+Mbzr6aDu3B4FO4PbjZdEoI=
12+
- secure: uEDWqegkGvkCo9qE5h3j/VvD007MKjwfsX9+CiWKK+nd+FrfqUak/LpSJiLYAdXePMqh/+jYynUWKsZFiLksmSkJK0U2Xkms9C2TynbuojlyTd8P1aUM9RNtOmS6FYtrmpQLxzUPNL8mIMcoTzIiZgABp8XDmW83NXKXSuKbXWpqO2oxHuVFHFNTnHW5fDs1VJJOrv+1oUICijAoy9X1iGZUTt0r+Vqb+uUt2XXlGzBhTBkGYIONDzI/4D9N7P4KJxrpiiKNpH8/EiWSGBmi1YCydW5KRLswdQYGWyvyKwRE9XBbLRd8CnEVPpB2ouL3CB2jGufzC1ZDKw7ehtyTCAZBFdIQMJHucJn0h0/qSFKBXO6Qvn7A5LfyxBpR0t+VG1cvtzE+v3BcIs6MkakZdVfOHoPczrOw6kG1Gbsjqd1TrYeT2evhzbiGIgyLf8UP5ReROlOwkpvyZSxqumuQtxNWIidzPRD9WQi8lD6F0p/C2hwqgmcDTBXV0+b6gmwOdn6rQVItTJj1j9V0omTh4rHsLHuycpXpBwLbABUaYvXxjHL+ZvQiydka1RqDsNDOZ5sOBEduPVtB3q1FN4WRBaAhXLOd4XwGys6K36JZgcxAEx4CVP5ECgU75cFkRC/qJhaOHI04qFdpGrfmv+ctmZQOBQyl+U0kDrV02kFftek=
1313
after_success: |
1414
sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev &&
1515
wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,27 +144,26 @@ Cell::new("foo2").style_spec("FrByc")
144144
Where **FrBybc** means **F**oreground: **r**ed, **B**ackground: **y**ellow, **b**old, **c**enter
145145

146146
With macros it's even simpler :
147-
> **Currently style in macros don't work on nightly rust because of _Type Ascription_. See issue [#11](https://github.com/phsym/prettytable-rs/issues/11) for details**
148147

149148
In rows, for each cells :
150149
```rust
151-
row![FrByb:"ABC", FrByb:"DEFG", "HIJKLMN"];
150+
row![FrByb->"ABC", FrByb->"DEFG", "HIJKLMN"];
152151
```
153152
Or for the whole row :
154153
```rust
155-
row![FY -> "styled", "bar", "foo"];
154+
row![FY => "styled", "bar", "foo"];
156155
```
157156
In tables, for each cells :
158157
```rust
159-
table!([FrBybl:"A", FrBybc:"B", FrBybr:"C"], [123, 234, 345, 456]);
158+
table!([FrBybl->"A", FrBybc->"B", FrBybr->"C"], [123, 234, 345, 456]);
160159
```
161160
Or for each rows :
162161
```rust
163-
table!([Frb -> "A", "B", "C"], [Frb -> 1, 2, 3, 4], [1, 2, 3]);
162+
table!([Frb => "A", "B", "C"], [Frb => 1, 2, 3, 4], [1, 2, 3]);
164163
```
165164
Or a mix :
166165
```rust
167-
table!([Frb -> "A", "B", "C"], [Frb:1, Fgi:2, 3, 4], [1, 2, 3]);
166+
table!([Frb => "A", "B", "C"], [Frb->1, Fgi->2, 3, 4], [1, 2, 3]);
168167
```
169168

170169
### List of style specifiers :

examples/style.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ fn main() {
1111
let _ = table!();
1212
let mut table = Table::new();
1313
// Add style to a cell
14-
table.add_row(row![FrByb:"ABC", "DEFG", "HIJKLMN"]);
14+
table.add_row(row![FrByb->"ABC", "DEFG", "HIJKLMN"]);
1515
// Add style to a full row
16-
table.add_row(row![FY -> "styled", "bar", "foo"]);
16+
table.add_row(row![FY => "styled", "bar", "foo"]);
1717
table.add_row(Row::new(vec![
1818
Cell::new("foobar2"),
1919
// Create a cell with a red foreground color
2020
Cell::new("bar2").with_style(Attr::ForegroundColor(color::RED)),
2121
// Create a cell with red foreground color, yellow background color, with bold characters
2222
Cell::new("foo2").style_spec("FrByb"),
2323
// Using the cell! macro
24-
cell!(Fr:"red")])
24+
cell!(Fr->"red")])
2525
);
2626

2727
table.printstd();
2828

2929
// Print a table with some styles on it :
3030
// FrBybl means : Foregound red, Background yellow, bold, left align
31-
ptable!([FrBybl:"A", "B", FrBybr:"C"], [123, 234, 345, 456], [Fg -> 1, 2, 3]);
31+
ptable!([FrBybl->"A", "B", FrBybr->"C"], [123, 234, 345, 456], [Fg => 1, 2, 3]);
3232

3333
// You can also apply style to full rows :
34-
let mut table = table!([Frb -> "A", "B", "C"], [1, 2, 3, 4], ["A\nBCCZZZ\nDDD", 2, table]);
34+
let mut table = table!([Frb => "A", "B", "C"], [1, 2, 3, 4], ["A\nBCCZZZ\nDDD", 2, table]);
3535
// Set a title line, with all text centered in the cell
36-
table.set_titles(row![c -> "Title 1", "Title 2"]);
36+
table.set_titles(row![c => "Title 1", "Title 2"]);
3737
table.printstd();
3838
}

src/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ impl Default for Cell {
251251
/// // Do something with the cell
252252
/// # drop(cell);
253253
/// // Create a cell with style (Red foreground, Bold, aligned to left);
254-
/// let styled = cell!(Frbl:"value");
254+
/// let styled = cell!(Frbl->"value");
255255
/// # drop(styled);
256256
/// # }
257257
/// ```
258258
#[macro_export]
259259
macro_rules! cell {
260260
() => ($crate::cell::Cell::default());
261261
($value:expr) => ($crate::cell::Cell::new(&$value.to_string()));
262-
($style:ident : $value:expr) => (cell!($value).style_spec(stringify!($style)));
262+
($style:ident -> $value:expr) => (cell!($value).style_spec(stringify!($style)));
263263
}
264264

265265
#[cfg(test)]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ impl <'a, T, E> Slice<'a, E> for T where T: AsRef<TableSlice<'a>>, [Row]: Index<
410410
/// ```
411411
/// # #[macro_use] extern crate prettytable;
412412
/// # fn main() {
413-
/// let tab = table!([FrByl:"Element1", Fgc:"Element2", "Element3"],
414-
/// [FrBy -> 1, 2, 3],
413+
/// let tab = table!([FrByl->"Element1", Fgc->"Element2", "Element3"],
414+
/// [FrBy => 1, 2, 3],
415415
/// ["A", "B", "C"]
416416
/// );
417417
/// # drop(tab);

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use term::{Attr, color};
1414
fn main() {
1515
let _ = table!();
1616
let mut table = Table::new();
17-
table.add_row(row![FrByb:"ABC", "DEFG", "HIJKLMN"]);
17+
table.add_row(row![FrByb->"ABC", "DEFG", "HIJKLMN"]);
1818
table.add_row(row!["foobar", "bar", "foo"]);
1919
table.add_row(row![]);
2020
// Add style to a full row
21-
table.add_row(row![FY -> "styled", "bar", "foo"]);
21+
table.add_row(row![FY => "styled", "bar", "foo"]);
2222
table.add_row(Row::new(vec![
2323
Cell::new("foobar2"),
2424
// Create a cell with a red foreground color
@@ -40,10 +40,10 @@ fn main() {
4040
// Print a table with some styles on it :
4141
// FrBybl means : Foregound red, Background yellow, bold, left align
4242
// d means : Default, do nothing
43-
ptable!([FrBybl:"A", "B", FrBybr:"C"], [d:123, 234, 345, 456]);
43+
ptable!([FrBybl->"A", "B", FrBybr->"C"], [d->123, 234, 345, 456]);
4444

4545
// You can also apply style to full rows :
46-
let mut table = table!([Frb -> "A", "B", "C"], [1, 2, 3, 4], ["A\nBCCZZZ\nDDD", 2, table]);
46+
let mut table = table!([Frb => "A", "B", "C"], [1, 2, 3, 4], ["A\nBCCZZZ\nDDD", 2, table]);
4747
table.set_titles(row!["Title 1", "Title 2"]);
4848
table.set_format(*consts::FORMAT_DEFAULT);
4949
table.printstd();

src/row.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ impl <T, A> From<T> for Row where A: ToString, T : IntoIterator<Item=A> {
174174
/// let row1 = row!["Element 1", "Element 2", "Element 3"];
175175
/// // Create a row with all cells formatted with red foreground color, yellow background color
176176
/// // bold, italic, align in the center of the cell
177-
/// let row2 = row![FrBybic -> "Element 1", "Element 2", "Element 3"];
177+
/// let row2 = row![FrBybic => "Element 1", "Element 2", "Element 3"];
178178
/// // Create a row with first cell in blue, second one in red, and last one with default style
179-
/// let row3 = row![Fb:"blue", Fr:"red", "normal"];
179+
/// let row3 = row![Fb->"blue", Fr->"red", "normal"];
180180
/// // Do something with rows
181181
/// # drop(row1);
182182
/// # drop(row2);
@@ -189,10 +189,10 @@ impl <T, A> From<T> for Row where A: ToString, T : IntoIterator<Item=A> {
189189
macro_rules! row {
190190
(($($out:tt)*); $value:expr) => (vec![$($out)* cell!($value)]);
191191
(($($out:tt)*); $value:expr, $($n:tt)*) => (row!(($($out)* cell!($value),); $($n)*));
192-
(($($out:tt)*); $style:ident : $value:expr) => (vec![$($out)* cell!($style : $value)]);
193-
(($($out:tt)*); $style:ident : $value:expr, $($n: tt)*) => (row!(($($out)* cell!($style : $value),); $($n)*));
192+
(($($out:tt)*); $style:ident -> $value:expr) => (vec![$($out)* cell!($style -> $value)]);
193+
(($($out:tt)*); $style:ident -> $value:expr, $($n: tt)*) => (row!(($($out)* cell!($style -> $value),); $($n)*));
194194

195195
($($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($content)), *]));
196-
($style:ident -> $($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($style : $content)), *]));
196+
($style:ident => $($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($style -> $content)), *]));
197197
($($content:tt)*) => ($crate::row::Row::new(row!((); $($content)*)));
198198
}

0 commit comments

Comments
 (0)