Skip to content

Commit ab2865d

Browse files
committed
Nits
1 parent b7f4210 commit ab2865d

10 files changed

Lines changed: 9 additions & 97 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ keywords = ["witx", "webassembly", "wasm", "generator", "bindgen"]
1212
readme = "README.md"
1313

1414
[dependencies]
15-
anyhow = "1.0.82"
16-
convert_case = "0.6.0"
15+
anyhow = "1.0.100"
16+
convert_case = "0.10.0"
1717
structopt = "0.3.26"
18-
strum = "0.26.2"
19-
strum_macros = "0.26.2"
18+
strum = "0.27.2"
19+
strum_macros = "0.27.2"
2020
witx = { package = "witnext", version = "0.10.0-beta3" }
2121

2222
[package.metadata.deb]

src/assemblyscript/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl ToLanguageRepresentation for ASType {
111111
}
112112

113113
pub fn escape_reserved_word(word: &str) -> String {
114-
if RESERVED.iter().any(|k| *k == word) {
114+
if RESERVED.contains(&word) {
115115
// If the camel-cased string matched any strict or reserved keywords, then
116116
// append a trailing underscore to the identifier we generate.
117117
format!("{}_", word)

src/cpp/common.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,6 @@ use super::tuple::Tuple;
22
use crate::astype::*;
33
use convert_case::{Case, Casing};
44

5-
pub trait IsNullable {
6-
fn is_nullable(&self) -> bool;
7-
}
8-
9-
impl IsNullable for ASType {
10-
fn is_nullable(&self) -> bool {
11-
matches!(
12-
self,
13-
ASType::ConstPtr(_)
14-
| ASType::MutPtr(_)
15-
| ASType::ReadBuffer(_)
16-
| ASType::WriteBuffer(_)
17-
| ASType::Enum(_)
18-
| ASType::Struct(_)
19-
| ASType::Tuple(_)
20-
| ASType::Union(_)
21-
)
22-
}
23-
}
24-
255
pub trait Normalize {
266
fn as_str(&self) -> &str;
277

@@ -33,21 +13,13 @@ pub trait Normalize {
3313
self.as_str().to_case(Case::Snake)
3414
}
3515

36-
fn as_fn_suffix(&self) -> String {
37-
self.as_str().to_case(Case::Snake)
38-
}
39-
4016
fn as_var(&self) -> String {
4117
self.as_str().to_case(Case::Snake)
4218
}
4319

4420
fn as_const(&self) -> String {
4521
self.as_str().to_case(Case::UpperSnake)
4622
}
47-
48-
fn as_namespace(&self) -> String {
49-
self.as_str().to_case(Case::Pascal)
50-
}
5123
}
5224

5325
impl<T: AsRef<str>> Normalize for T {

src/doc/common.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@ pub trait Normalize {
1717
format!("[`{}()`]({})", self.as_str(), self.as_link())
1818
}
1919

20-
fn as_fn_suffix(&self) -> String {
21-
self.as_str().to_string()
22-
}
23-
2420
fn as_var(&self) -> String {
2521
format!("**`{}`**", self.as_str())
2622
}
2723

2824
fn as_const(&self) -> String {
2925
format!("**`{}`**", self.as_str())
3026
}
31-
32-
fn as_namespace(&self) -> String {
33-
format!("**[`{}`]({})**", self.as_str(), self.as_link())
34-
}
3527
}
3628

3729
impl<T: AsRef<str>> Normalize for T {

src/doc/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl DocGenerator {
6969
let mut w = w.new_block();
7070
for result in &results {
7171
let result_as_ptr = ASType::MutPtr(result.1.clone());
72-
w.write_line(&result_as_ptr.as_lang())?;
72+
w.write_line(result_as_ptr.as_lang())?;
7373
}
7474
}
7575
}

src/overview/common.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,13 @@ pub trait Normalize {
1111
self.as_str().to_string()
1212
}
1313

14-
fn as_fn_suffix(&self) -> String {
15-
self.as_str().to_string()
16-
}
17-
1814
fn as_var(&self) -> String {
1915
self.as_str().to_string()
2016
}
2117

2218
fn as_const(&self) -> String {
2319
self.as_str().to_string()
2420
}
25-
26-
fn as_namespace(&self) -> String {
27-
self.as_str().to_string()
28-
}
2921
}
3022

3123
impl<T: AsRef<str>> Normalize for T {

src/pretty_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<W: Write> PrettyWriter<W> {
127127
/// Write multiple indented lines
128128
pub fn write_lines<T: AsRef<[u8]>>(&mut self, buf: T) -> Result<&mut Self, Error> {
129129
let buf = buf.as_ref();
130-
for line in buf.lines().flatten() {
130+
for line in buf.lines().map_while(Result::ok) {
131131
self.write_line(line)?;
132132
}
133133
Ok(self)

src/rust/common.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,6 @@ use convert_case::{Case, Casing};
33
use super::tuple::Tuple;
44
use crate::astype::*;
55

6-
pub trait IsNullable {
7-
fn is_nullable(&self) -> bool;
8-
}
9-
10-
impl IsNullable for ASType {
11-
fn is_nullable(&self) -> bool {
12-
matches!(
13-
self,
14-
ASType::ConstPtr(_)
15-
| ASType::MutPtr(_)
16-
| ASType::ReadBuffer(_)
17-
| ASType::WriteBuffer(_)
18-
| ASType::Enum(_)
19-
| ASType::Struct(_)
20-
| ASType::Tuple(_)
21-
| ASType::Union(_)
22-
)
23-
}
24-
}
25-
266
pub trait Normalize {
277
fn as_str(&self) -> &str;
288

src/zig/common.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,13 @@ use convert_case::{Case, Casing};
33
use super::tuple::Tuple;
44
use crate::astype::*;
55

6-
pub trait IsNullable {
7-
fn is_nullable(&self) -> bool;
8-
}
9-
10-
impl IsNullable for ASType {
11-
fn is_nullable(&self) -> bool {
12-
matches!(
13-
self,
14-
ASType::ConstPtr(_)
15-
| ASType::MutPtr(_)
16-
| ASType::ReadBuffer(_)
17-
| ASType::WriteBuffer(_)
18-
| ASType::Enum(_)
19-
| ASType::Struct(_)
20-
| ASType::Tuple(_)
21-
| ASType::Union(_)
22-
)
23-
}
24-
}
25-
266
pub trait Normalize {
277
fn as_str(&self) -> &str;
288

299
fn as_type(&self) -> String {
3010
self.as_str().to_case(Case::Pascal)
3111
}
3212

33-
fn as_fn(&self) -> String {
34-
self.as_str().to_case(Case::Camel)
35-
}
36-
3713
fn as_fn_suffix(&self) -> String {
3814
self.as_str().to_case(Case::UpperCamel)
3915
}
@@ -112,7 +88,7 @@ impl ToLanguageRepresentation for ASType {
11288
/// If the given word conflicts with a keyword, a trailing underscore will be
11389
/// appended.
11490
pub fn escape_reserved_word(word: &str) -> String {
115-
if RESERVED.iter().any(|k| *k == word) {
91+
if RESERVED.contains(&word) {
11692
// If the camel-cased string matched any strict or reserved keywords, then
11793
// append a trailing underscore to the identifier we generate.
11894
format!("{}_", word)

src/zig/union.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl ZigGenerator {
135135
w.write_line("member = extern union {")?;
136136
{
137137
let mut w = w.new_block();
138-
for (_i, member) in union_.members.iter().enumerate() {
138+
for member in &union_.members {
139139
let member_is_void = matches!(member.type_.as_ref(), ASType::Void);
140140
if !member_is_void {
141141
w.write_line(format!(

0 commit comments

Comments
 (0)