Skip to content

Commit 58092f2

Browse files
committed
ran cargo clippy --fix -- -Wclippy::use_self
1 parent 8ec2428 commit 58092f2

File tree

9 files changed

+68
-68
lines changed

9 files changed

+68
-68
lines changed

crates/gh-workflow/src/cargo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub struct Cargo {
2525

2626
impl Cargo {
2727
/// Creates a new `Cargo` instance with the specified command.
28-
pub fn new<T: ToString>(cmd: T) -> Cargo {
29-
Cargo {
28+
pub fn new<T: ToString>(cmd: T) -> Self {
29+
Self {
3030
command: cmd.to_string(),
3131
id: Default::default(),
3232
name: Default::default(),

crates/gh-workflow/src/container.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Volume {
7878
pub fn new(volume_str: &str) -> Option<Self> {
7979
let parts: Vec<&str> = volume_str.split(':').collect();
8080
if parts.len() == 2 {
81-
Some(Volume {
81+
Some(Self {
8282
source: parts[0].to_string(),
8383
destination: parts[1].to_string(),
8484
})

crates/gh-workflow/src/ctx.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum Step {
4343

4444
impl<A> Context<A> {
4545
fn new() -> Self {
46-
Context { marker: PhantomData, step: Step::Root }
46+
Self { marker: PhantomData, step: Step::Root }
4747
}
4848

4949
fn select<B>(&self, path: impl Into<String>) -> Context<B> {
@@ -56,7 +56,7 @@ impl<A> Context<A> {
5656
}
5757
}
5858

59-
pub fn eq(&self, other: Context<A>) -> Context<bool> {
59+
pub fn eq(&self, other: Self) -> Context<bool> {
6060
Context {
6161
marker: Default::default(),
6262
step: Step::Eq {
@@ -66,7 +66,7 @@ impl<A> Context<A> {
6666
}
6767
}
6868

69-
pub fn and(&self, other: Context<A>) -> Context<bool> {
69+
pub fn and(&self, other: Self) -> Context<bool> {
7070
Context {
7171
marker: Default::default(),
7272
step: Step::And {
@@ -76,7 +76,7 @@ impl<A> Context<A> {
7676
}
7777
}
7878

79-
pub fn or(&self, other: Context<A>) -> Context<bool> {
79+
pub fn or(&self, other: Self) -> Context<bool> {
8080
Context {
8181
marker: Default::default(),
8282
step: Step::Or {
@@ -88,8 +88,8 @@ impl<A> Context<A> {
8888
}
8989

9090
impl Context<String> {
91-
pub fn concat(&self, other: Context<String>) -> Context<String> {
92-
Context {
91+
pub fn concat(&self, other: Self) -> Self {
92+
Self {
9393
marker: Default::default(),
9494
step: Step::Concat {
9595
left: Box::new(self.step.clone()),
@@ -199,27 +199,27 @@ impl Context<Github> {
199199
impl fmt::Display for Step {
200200
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
201201
match self {
202-
Step::Root => write!(f, ""),
203-
Step::Select { name, object } => {
204-
if matches!(**object, Step::Root) {
202+
Self::Root => write!(f, ""),
203+
Self::Select { name, object } => {
204+
if matches!(**object, Self::Root) {
205205
write!(f, "{name}")
206206
} else {
207207
write!(f, "{object}.{name}")
208208
}
209209
}
210-
Step::Eq { left, right } => {
210+
Self::Eq { left, right } => {
211211
write!(f, "{left} == {right}")
212212
}
213-
Step::And { left, right } => {
213+
Self::And { left, right } => {
214214
write!(f, "{left} && {right}")
215215
}
216-
Step::Or { left, right } => {
216+
Self::Or { left, right } => {
217217
write!(f, "{left} || {right}")
218218
}
219-
Step::Literal(value) => {
219+
Self::Literal(value) => {
220220
write!(f, "'{value}'")
221221
}
222-
Step::Concat { left, right } => {
222+
Self::Concat { left, right } => {
223223
write!(f, "{left}{right}")
224224
}
225225
}
@@ -234,13 +234,13 @@ impl<A> fmt::Display for Context<A> {
234234

235235
impl<A> From<Context<A>> for Expression {
236236
fn from(value: Context<A>) -> Self {
237-
Expression::new(value.to_string())
237+
Self::new(value.to_string())
238238
}
239239
}
240240

241241
impl<T: Into<String>> From<T> for Context<String> {
242242
fn from(value: T) -> Self {
243-
Context {
243+
Self {
244244
marker: Default::default(),
245245
step: Step::Literal(value.into()),
246246
}

crates/gh-workflow/src/env.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct Env(pub IndexMap<String, Value>);
1515
impl From<IndexMap<String, Value>> for Env {
1616
/// Converts an `IndexMap` into an `Env`.
1717
fn from(value: IndexMap<String, Value>) -> Self {
18-
Env(value)
18+
Self(value)
1919
}
2020
}
2121

@@ -27,12 +27,12 @@ impl Env {
2727
"GITHUB_TOKEN".to_string(),
2828
Value::from("${{ secrets.GITHUB_TOKEN }}"),
2929
);
30-
Env(map)
30+
Self(map)
3131
}
3232

3333
/// Creates a new `Env` with a specified key-value pair.
3434
pub fn new<K: ToString, V: Into<Value>>(key: K, value: V) -> Self {
35-
Env::default().add(key, value)
35+
Self::default().add(key, value)
3636
}
3737

3838
/// Adds an environment variable to the `Env`.
@@ -48,6 +48,6 @@ impl<S1: Display, S2: Display> From<(S1, S2)> for Env {
4848
fn from(value: (S1, S2)) -> Self {
4949
let mut index_map: IndexMap<String, Value> = IndexMap::new();
5050
index_map.insert(value.0.to_string(), Value::String(value.1.to_string()));
51-
Env(index_map)
51+
Self(index_map)
5252
}
5353
}

crates/gh-workflow/src/job.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ where
2323
{
2424
/// Converts a value into a `RunsOn` instance.
2525
fn from(value: T) -> Self {
26-
RunsOn(value.into())
26+
Self(value.into())
2727
}
2828
}
2929

crates/gh-workflow/src/release_plz.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pub enum Command {
5050
impl std::fmt::Display for Command {
5151
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5252
match self {
53-
Command::ReleasePR => write!(f, "release-pr"),
54-
Command::Release => write!(f, "release"),
53+
Self::ReleasePR => write!(f, "release-pr"),
54+
Self::Release => write!(f, "release"),
5555
}
5656
}
5757
}
@@ -65,8 +65,8 @@ pub enum Backend {
6565
impl std::fmt::Display for Backend {
6666
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6767
match self {
68-
Backend::GitHub => write!(f, "github"),
69-
Backend::Gitea => write!(f, "gitea"),
68+
Self::GitHub => write!(f, "github"),
69+
Self::Gitea => write!(f, "gitea"),
7070
}
7171
}
7272
}

crates/gh-workflow/src/rust_flag.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,47 @@ pub enum Lint {
2323
}
2424

2525
impl core::ops::Add for RustFlags {
26-
type Output = RustFlags;
26+
type Output = Self;
2727

2828
fn add(self, rhs: Self) -> Self::Output {
29-
RustFlags::Combine(Box::new(self), Box::new(rhs))
29+
Self::Combine(Box::new(self), Box::new(rhs))
3030
}
3131
}
3232

3333
impl RustFlags {
3434
pub fn allow<S: ToString>(name: S) -> Self {
35-
RustFlags::Lint(name.to_string(), Lint::Allow)
35+
Self::Lint(name.to_string(), Lint::Allow)
3636
}
3737

3838
pub fn warn<S: ToString>(name: S) -> Self {
39-
RustFlags::Lint(name.to_string(), Lint::Warn)
39+
Self::Lint(name.to_string(), Lint::Warn)
4040
}
4141

4242
pub fn deny<S: ToString>(name: S) -> Self {
43-
RustFlags::Lint(name.to_string(), Lint::Deny)
43+
Self::Lint(name.to_string(), Lint::Deny)
4444
}
4545

4646
pub fn forbid<S: ToString>(name: S) -> Self {
47-
RustFlags::Lint(name.to_string(), Lint::Forbid)
47+
Self::Lint(name.to_string(), Lint::Forbid)
4848
}
4949

5050
pub fn codegen<S: ToString>(name: S) -> Self {
51-
RustFlags::Lint(name.to_string(), Lint::Codegen)
51+
Self::Lint(name.to_string(), Lint::Codegen)
5252
}
5353
}
5454

5555
impl Display for RustFlags {
5656
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
5757
match self {
58-
RustFlags::Lint(name, lint) => match lint {
58+
Self::Lint(name, lint) => match lint {
5959
Lint::Allow => write!(f, "-A{name}"),
6060
Lint::Warn => write!(f, "-W{name}"),
6161
Lint::Deny => write!(f, "-D{name}"),
6262
Lint::Forbid => write!(f, "-F{name}"),
6363
Lint::Codegen => write!(f, "-C{name}"),
6464
Lint::Experiment => write!(f, "-Z{name}"),
6565
},
66-
RustFlags::Combine(lhs, rhs) => write!(f, "{lhs} {rhs}"),
66+
Self::Combine(lhs, rhs) => write!(f, "{lhs} {rhs}"),
6767
}
6868
}
6969
}
@@ -72,6 +72,6 @@ impl From<RustFlags> for Env {
7272
fn from(value: RustFlags) -> Self {
7373
let mut env = IndexMap::default();
7474
env.insert("RUSTFLAGS".to_string(), Value::from(value.to_string()));
75-
Env::from(env)
75+
Self::from(env)
7676
}
7777
}

crates/gh-workflow/src/step.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub struct Input(#[serde(skip_serializing_if = "IndexMap::is_empty")] pub IndexM
7373
impl From<IndexMap<String, Value>> for Input {
7474
/// Converts an `IndexMap` into an `Input`.
7575
fn from(value: IndexMap<String, Value>) -> Self {
76-
Input(value)
76+
Self(value)
7777
}
7878
}
7979

@@ -162,7 +162,7 @@ pub struct StepValue {
162162
impl StepValue {
163163
/// Creates a new `StepValue` that runs the provided shell command.
164164
pub fn run<T: ToString>(cmd: T) -> Self {
165-
StepValue { run: Some(cmd.to_string()), ..Default::default() }
165+
Self { run: Some(cmd.to_string()), ..Default::default() }
166166
}
167167

168168
/// Creates a new `StepValue` that uses an action.
@@ -171,7 +171,7 @@ impl StepValue {
171171
repo: Repo,
172172
version: Version,
173173
) -> Self {
174-
StepValue {
174+
Self {
175175
uses: Some(format!(
176176
"{}/{}@{}",
177177
owner.to_string(),
@@ -197,7 +197,7 @@ impl<T> Step<T> {
197197

198198
impl Step<()> {
199199
pub fn new(name: impl ToString) -> Self {
200-
Step {
200+
Self {
201201
value: StepValue::default().name(name.to_string()),
202202
marker: Default::default(),
203203
}
@@ -222,7 +222,7 @@ impl Step<()> {
222222
/// Represents a step that uses an action.
223223
impl Step<Use> {
224224
/// Creates a step pointing to the default GitHub's Checkout Action.
225-
pub fn checkout() -> Step<Use> {
225+
pub fn checkout() -> Self {
226226
Step::new("Checkout Code").uses("actions", "checkout", "v5")
227227
}
228228

@@ -246,13 +246,13 @@ impl<S1: ToString, S2: ToString> From<(S1, S2)> for Input {
246246
fn from(value: (S1, S2)) -> Self {
247247
let mut index_map: IndexMap<String, Value> = IndexMap::new();
248248
index_map.insert(value.0.to_string(), Value::String(value.1.to_string()));
249-
Input(index_map)
249+
Self(index_map)
250250
}
251251
}
252252

253253
impl Step<Toolchain> {
254-
pub fn toolchain() -> Step<Toolchain> {
255-
Step { value: Default::default(), marker: Toolchain::default() }
254+
pub fn toolchain() -> Self {
255+
Self { value: Default::default(), marker: Toolchain::default() }
256256
}
257257

258258
pub fn add_version(mut self, version: Version) -> Self {

0 commit comments

Comments
 (0)