Skip to content

Commit

Permalink
fix: add const fn and copy where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytten committed Jul 7, 2023
1 parent bd153b5 commit 3aefd15
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions caido-convert/src/encoding/base32hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use crate::Operation;
use crate::OperationError;

#[derive(Clone)]
#[derive(Clone, Copy)]
#[cfg_attr(target_family = "wasm", derive(Serialize, Deserialize))]
pub struct Base32HexDecode {}

Expand All @@ -18,7 +18,7 @@ impl Operation for Base32HexDecode {
}

impl Base32HexDecode {
pub fn new() -> Self {
pub const fn new() -> Self {
Base32HexDecode {}
}
}
Expand All @@ -34,7 +34,7 @@ impl Operation for Base32HexEncode {
}

impl Base32HexEncode {
pub fn new() -> Self {
pub const fn new() -> Self {
Base32HexEncode {}
}
}
Expand Down
6 changes: 3 additions & 3 deletions caido-convert/src/encoding/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use crate::Operation;
use crate::OperationError;

#[derive(Clone)]
#[derive(Clone, Copy)]
#[cfg_attr(target_family = "wasm", derive(Serialize, Deserialize))]
#[cfg_attr(target_family = "wasm", serde(rename_all = "snake_case"))]
pub enum Base64Format {
Expand Down Expand Up @@ -35,7 +35,7 @@ impl Operation for Base64Decode {
}

impl Base64Decode {
pub fn new(format: Base64Format, pad: bool) -> Self {
pub const fn new(format: Base64Format, pad: bool) -> Self {
Base64Decode { format, pad }
}
}
Expand All @@ -61,7 +61,7 @@ impl Operation for Base64Encode {
}

impl Base64Encode {
pub fn new(format: Base64Format, pad: bool) -> Self {
pub const fn new(format: Base64Format, pad: bool) -> Self {
Base64Encode { format, pad }
}
}
Expand Down
6 changes: 3 additions & 3 deletions caido-convert/src/encoding/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct HexDecode {
delimiter: Option<String>,
}

#[derive(Clone)]
#[derive(Clone, Copy)]
#[cfg_attr(target_family = "wasm", derive(Serialize, Deserialize))]
pub enum HexFormat {
Upper,
Expand All @@ -34,7 +34,7 @@ impl Operation for HexDecode {
}

impl HexDecode {
pub fn new(prefix: Option<String>, delimiter: Option<String>) -> Self {
pub const fn new(prefix: Option<String>, delimiter: Option<String>) -> Self {
HexDecode { prefix, delimiter }
}
}
Expand Down Expand Up @@ -79,7 +79,7 @@ impl Operation for HexEncode {
}

impl HexEncode {
pub fn new(format: HexFormat, prefix: Option<String>, delimiter: Option<String>) -> Self {
pub const fn new(format: HexFormat, prefix: Option<String>, delimiter: Option<String>) -> Self {
HexEncode {
format,
prefix,
Expand Down
4 changes: 2 additions & 2 deletions caido-convert/src/encoding/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Operation for HtmlDecode {
}

impl HtmlDecode {
pub fn new() -> Self {
pub const fn new() -> Self {
HtmlDecode {}
}
}
Expand All @@ -88,7 +88,7 @@ impl Operation for HtmlEncode {
}

impl HtmlEncode {
pub fn new() -> Self {
pub const fn new() -> Self {
HtmlEncode {}
}
}
Expand Down

0 comments on commit 3aefd15

Please sign in to comment.