Skip to content

Commit 7656698

Browse files
authored
Upgrade dependencies and rust version to 2024 (#49)
* Upgrade dependencies * Fix clippy errors * Upgrade rust version to 2024 * Fix formatting
1 parent 660cf6e commit 7656698

File tree

16 files changed

+53
-86
lines changed

16 files changed

+53
-86
lines changed

.github/workflows/gh-pages.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[workspace]
22
members = ["cli-table", "cli-table-derive", "test-suite"]
3+
resolver = "3"

cli-table-derive/Cargo.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ categories = ["command-line-interface"]
1010
keywords = ["table", "cli", "format"]
1111
readme = "README.md"
1212
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-*"]
13-
edition = "2018"
13+
edition = "2024"
1414

1515
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1616

17+
[features]
18+
default = []
19+
doc = []
20+
1721
[dependencies]
18-
proc-macro2 = "1.0.86"
19-
syn = "1.0.109"
20-
quote = "1.0.36"
22+
proc-macro2 = "1.0.94"
23+
syn = "2.0.100"
24+
quote = "1.0.40"
2125

2226
[lib]
2327
proc-macro = true

cli-table-derive/src/context/fields.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use proc_macro2::{Span, TokenStream};
22
use quote::ToTokens;
33
use syn::{
4-
spanned::Spanned, Data, DeriveInput, Error, Expr, Field as SynField, Fields as SynFields,
5-
Ident, Index, Lit, LitBool, LitStr, Result,
4+
Data, DeriveInput, Error, Expr, Field as SynField, Fields as SynFields, Ident, Index, Lit,
5+
LitBool, LitStr, Result, spanned::Spanned,
66
};
77

88
use crate::utils::get_attributes;

cli-table-derive/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod table;
1010
mod utils;
1111

1212
use proc_macro::TokenStream;
13-
use syn::{parse_macro_input, DeriveInput};
13+
use syn::{DeriveInput, parse_macro_input};
1414

1515
#[proc_macro_derive(Table, attributes(table))]
1616
/// Derive macro to implementing `cli_table` traits

cli-table-derive/src/utils.rs

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
1-
use syn::{spanned::Spanned, Attribute, Error, Lit, LitBool, Meta, NestedMeta, Path, Result};
1+
use syn::{Attribute, Error, Lit, LitBool, Path, Result, spanned::Spanned};
22

33
pub fn get_attributes(attrs: &[Attribute]) -> Result<Vec<(Path, Lit)>> {
44
let mut attributes = Vec::new();
55

66
for attribute in attrs {
7-
if !attribute.path.is_ident("table") {
7+
if !attribute.path().is_ident("table") {
88
continue;
99
}
1010

11-
let meta = attribute.parse_meta()?;
12-
13-
let meta_list = match meta {
14-
Meta::List(meta_list) => Ok(meta_list),
15-
bad => Err(Error::new_spanned(
16-
bad,
17-
"Attributes should be of type: #[table(key = \"value\", ..)]",
18-
)),
19-
}?;
20-
21-
for nested_meta in meta_list.nested.into_iter() {
22-
let meta = match nested_meta {
23-
NestedMeta::Meta(meta) => Ok(meta),
24-
bad => Err(Error::new_spanned(
25-
bad,
26-
"Attributes should be of type: #[table(key = \"value\", ..)]",
27-
)),
28-
}?;
29-
30-
match meta {
31-
Meta::Path(path) => {
32-
let lit = LitBool {
11+
if attribute
12+
.parse_nested_meta(|meta| {
13+
let path = meta.path.clone();
14+
let lit = meta
15+
.value()
16+
.ok()
17+
.map(|v| v.parse())
18+
.transpose()?
19+
.unwrap_or(Lit::from(LitBool {
3320
value: true,
3421
span: path.span(),
35-
}
36-
.into();
37-
attributes.push((path, lit));
38-
}
39-
Meta::NameValue(meta_name_value) => {
40-
attributes.push((meta_name_value.path, meta_name_value.lit));
41-
}
42-
bad => return Err(Error::new_spanned(
43-
bad,
44-
"Attributes should be of type: #[table(key = \"value\", ..)] or #[table(bool)]",
45-
)),
46-
}
22+
}));
23+
24+
attributes.push((path, lit));
25+
26+
Ok(())
27+
})
28+
.is_err()
29+
{
30+
return Err(Error::new_spanned(
31+
attribute,
32+
"Attributes should be of type: #[table(key = \"value\", ..)] or #[table(bool)]",
33+
));
4734
}
4835
}
4936

cli-table/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ categories = ["command-line-interface"]
1010
keywords = ["table", "cli", "format"]
1111
readme = "README.md"
1212
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-*"]
13-
edition = "2018"
13+
edition = "2024"
1414

1515
[lib]
1616
name = "cli_table"
@@ -20,9 +20,9 @@ path = "src/lib.rs"
2020

2121
[dependencies]
2222
cli-table-derive = { version = "0.4.6", path = "../cli-table-derive", optional = true }
23-
csv = { version = "1.3.0", optional = true }
23+
csv = { version = "1.3.1", optional = true }
2424
termcolor = "1.4.1"
25-
unicode-width = "0.1.13"
25+
unicode-width = "0.2.0"
2626

2727
[features]
2828
default = ["csv", "derive"]

cli-table/examples/csv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{convert::TryFrom, io::Result};
22

3-
use cli_table::{print_stdout, TableStruct};
3+
use cli_table::{TableStruct, print_stdout};
44
use csv::ReaderBuilder;
55

66
fn main() -> Result<()> {

cli-table/examples/nested.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::io::Result;
22

3-
use cli_table::{format::Justify, Cell, Style, Table};
3+
use cli_table::{Cell, Style, Table, format::Justify};
44

55
fn main() -> Result<()> {
66
let nested_table = vec![vec![20.cell()]].table();

cli-table/examples/simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::io::Result;
22

3-
use cli_table::{format::Justify, print_stdout, Cell, Style, Table};
3+
use cli_table::{Cell, Style, Table, format::Justify, print_stdout};
44

55
fn main() -> Result<()> {
66
let table = vec![

0 commit comments

Comments
 (0)