Skip to content

Commit

Permalink
Use more idiomatic parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
conways-glider committed Mar 12, 2024
1 parent 0a47993 commit 2e93b97
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "identicon-rs"
version = "4.0.3"
version = "5.0.0"
authors = ["Nia Maxwell <nia@conwaysglider.com>"]
edition = "2021"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Identicon-rs

[![Rust](https://github.com/conways-glider/identicon-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/conways-glider/identicon-rs/actions/workflows/rust.yml)
[![dependency status](https://deps.rs/crate/identicon-rs/4.0.3/status.svg)](https://deps.rs/crate/identicon-rs/4.0.3)
[![dependency status](https://deps.rs/crate/identicon-rs/5.0.0/status.svg)](https://deps.rs/crate/identicon-rs/5.0.0)

This is an Identicon implementation in rust.

Expand Down
2 changes: 1 addition & 1 deletion examples/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() -> Result<(), IdenticonError> {
let test_string = "identicon_rs";

// Stored example
let identicon_conways_glider = Identicon::new(conways_glider);
let identicon_conways_glider = Identicon::new(&conways_glider);
identicon_conways_glider.save_image("output_1.png")?;

// Chained example with no border
Expand Down
17 changes: 4 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ pub struct Identicon {
/// This is a wrapper around [`identicon_rs::Identicon::new`].
///
/// [`identicon_rs::Identicon::new`]: struct.Identicon.html#method.new
pub fn new<T>(input_value: T) -> Identicon
where
T: AsRef<str>,
{
pub fn new(input_value: &str) -> Identicon {
Identicon::new(input_value)
}

Expand All @@ -52,21 +49,15 @@ impl Identicon {
/// - scale: 500
/// - background_color: (240, 240, 240)
/// - mirrored: true
pub fn new<T>(input_value: T) -> Self
where
T: AsRef<str>,
{
pub fn new(input_value: &str) -> Self {
let mut identicon = Self::default();
identicon.set_input(input_value);
identicon
}

/// Sets the identicon input value, regenerating the hash.
pub fn set_input<T>(&mut self, input_value: T) -> &mut Self
where
T: AsRef<str>,
{
self.hash = Self::hash_value(input_value.as_ref());
pub fn set_input(&mut self, input_value: &str) -> &mut Self {
self.hash = Self::hash_value(input_value);
self
}

Expand Down

0 comments on commit 2e93b97

Please sign in to comment.