Skip to content

Commit

Permalink
Merge pull request #11 from jrmuizel/master
Browse files Browse the repository at this point in the history
Remove unneeded calls to to_owned().
  • Loading branch information
buntine committed Jul 9, 2018
2 parents c0592f0 + 5351e61 commit 5efb6ed
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 212 deletions.
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -79,7 +79,7 @@ use barcoders::sym::ean13::*;

// Each encoder accepts a String to be encoded. Valid data is barcode-specific
// and thus constructors return an Result<T, barcoders::error::Error>.
let barcode = EAN13::new("593456661897".to_owned()).unwrap();
let barcode = EAN13::new("593456661897").unwrap();

// The `encode` method returns a Vec<u8> of the binary representation of the
// generated barcode. This is useful if you want to add your own generator.
Expand All @@ -97,7 +97,7 @@ use std::io::BufWriter;
use std::fs::File;
use std::path::Path;

let barcode = Code39::new("1ISTHELONELIESTNUMBER".to_owned()).unwrap();
let barcode = Code39::new("1ISTHELONELIESTNUMBER").unwrap();
let png = Image::png(80); // You must specify the height in pixels.
let encoded = barcode.encode();

Expand All @@ -115,7 +115,7 @@ writer.write(&bytes[..]).unwrap();

You can also request an [image::RgbaImage](http://www.piston.rs/image/image/type.RgbaImage.html), which you can manipulate yourself:
```rust
let barcode = Code39::new("BEELZEBUB".to_owned()).unwrap();
let barcode = Code39::new("BEELZEBUB").unwrap();
let buffer = Image::image_buffer(100);
let encoded = barcode.encode();
let img = buffer.generate_buffer(&encoded[..]).unwrap();
Expand Down Expand Up @@ -147,7 +147,7 @@ use std::io::BufWriter;
use std::fs::File;
use std::path::Path;

let barcode = Code39::new("56DFU4A777H".to_owned()).unwrap();
let barcode = Code39::new("56DFU4A777H").unwrap();
let svg = SVG::new(200); // You must specify the height in pixels.
let encoded = barcode.encode();
let data: String = svg.generate(&encoded).unwrap();
Expand Down Expand Up @@ -176,7 +176,7 @@ extern crate barcoders;
use barcoders::sym::ean13::*;
use barcoders::generators::ascii::*;

let barcode = EAN13::new("750103131130".to_owned()).unwrap();
let barcode = EAN13::new("750103131130").unwrap();
let encoded = barcode.encode();

let ascii = ASCII::new();
Expand All @@ -194,7 +194,7 @@ assert_eq!(ascii.unwrap(),
# # ## # # ### ## # # ### #### # ## ## # # # # ## ## ## ## # # ### # ### # # #
# # ## # # ### ## # # ### #### # ## ## # # # # ## ## ## ## # # ### # ### # # #
# # ## # # ### ## # # ### #### # ## ## # # # # ## ## ## ## # # ### # ### # # #
".trim().to_owned());
".trim());
```


Expand All @@ -208,7 +208,7 @@ extern crate barcoders;
use barcoders::sym::codabar::*;
use barcoders::generators::json::*;

let codabar = Codabar::new("A98B".to_owned()).unwrap();
let codabar = Codabar::new("A98B").unwrap();
let json = JSON::new();
let generated = json.generate(&codabar.encode()[..]);

Expand Down
64 changes: 32 additions & 32 deletions src/generators/ascii.rs
Expand Up @@ -68,7 +68,7 @@ mod tests {

#[test]
fn ean_13_as_ascii() {
let ean13 = EAN13::new("750103131130".to_owned()).unwrap();
let ean13 = EAN13::new("750103131130").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&ean13.encode()[..]).unwrap();

Expand All @@ -84,12 +84,12 @@ mod tests {
# # ## # # ### ## # # ### #### # ## ## # # # # ## ## ## ## # # ### # ### # # #
# # ## # # ### ## # # ### #### # ## ## # # # # ## ## ## ## # # ### # ### # # #
# # ## # # ### ## # # ### #### # ## ## # # # # ## ## ## ## # # ### # ### # # #
".trim().to_owned());
".trim());
}

#[test]
fn ean_13_as_ascii_small_height_double_width() {
let ean13 = EAN13::new("750103131130".to_owned()).unwrap();
let ean13 = EAN13::new("750103131130").unwrap();
let ascii = ASCII{height: 6, xdim: 2};
let generated = ascii.generate(&ean13.encode()[..]).unwrap();

Expand All @@ -101,12 +101,12 @@ mod tests {
## ## #### ## ## ###### #### ## ## ###### ######## ## #### #### ## ## ## ## #### #### #### #### ## ## ###### ## ###### ## ## ##
## ## #### ## ## ###### #### ## ## ###### ######## ## #### #### ## ## ## ## #### #### #### #### ## ## ###### ## ###### ## ## ##
## ## #### ## ## ###### #### ## ## ###### ######## ## #### #### ## ## ## ## #### #### #### #### ## ## ###### ## ###### ## ## ##
".trim().to_owned());
".trim());
}

#[test]
fn ean_8_as_ascii() {
let ean8 = EAN8::new("1234567".to_owned()).unwrap();
let ean8 = EAN8::new("1234567").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&ean8.encode()[..]).unwrap();

Expand All @@ -122,12 +122,12 @@ mod tests {
# # ## # # ## #### # # ## # # # ### # # # # ### # # #
# # ## # # ## #### # # ## # # # ### # # # # ### # # #
# # ## # # ## #### # # ## # # # ### # # # # ### # # #
".trim().to_owned());
".trim());
}

#[test]
fn ean_8_as_ascii_small_height_double_width() {
let ean8 = EAN8::new("1234567".to_owned()).unwrap();
let ean8 = EAN8::new("1234567").unwrap();
let ascii = ASCII{height: 5, xdim: 2};
let generated = ascii.generate(&ean8.encode()[..]).unwrap();

Expand All @@ -138,12 +138,12 @@ mod tests {
## ## #### ## ## #### ######## ## ## #### ## ## ## ###### ## ## ## ## ###### ## ## ##
## ## #### ## ## #### ######## ## ## #### ## ## ## ###### ## ## ## ## ###### ## ## ##
## ## #### ## ## #### ######## ## ## #### ## ## ## ###### ## ## ## ## ###### ## ## ##
".trim().to_owned());
".trim());
}

#[test]
fn code_39_as_ascii() {
let code39 = Code39::new("TEST8052".to_owned()).unwrap();
let code39 = Code39::new("TEST8052").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&code39.encode()[..]).unwrap();

Expand All @@ -159,12 +159,12 @@ mod tests {
# # ## ## # # # ## ## # ## # ## # # # ## # ## # # # ## ## # ## # # ## # # # ## ## # ## # ## # # # ## # # ## # # ## ## #
# # ## ## # # # ## ## # ## # ## # # # ## # ## # # # ## ## # ## # # ## # # # ## ## # ## # ## # # # ## # # ## # # ## ## #
# # ## ## # # # ## ## # ## # ## # # # ## # ## # # # ## ## # ## # # ## # # # ## ## # ## # ## # # # ## # # ## # # ## ## #
".trim().to_owned());
".trim());
}

#[test]
fn code_39_as_ascii_small_height_double_weight() {
let code39 = Code39::new("1234".to_owned()).unwrap();
let code39 = Code39::new("1234").unwrap();
let ascii = ASCII{height: 7, xdim: 2};
let generated = ascii.generate(&code39.encode()[..]).unwrap();

Expand All @@ -177,12 +177,12 @@ mod tests {
## ## #### #### ## #### ## ## ## #### ## #### ## ## #### #### #### ## ## ## ## ## #### ## #### ## ## #### #### ##
## ## #### #### ## #### ## ## ## #### ## #### ## ## #### #### #### ## ## ## ## ## #### ## #### ## ## #### #### ##
## ## #### #### ## #### ## ## ## #### ## #### ## ## #### #### #### ## ## ## ## ## #### ## #### ## ## #### #### ##
".trim().to_owned());
".trim());
}

#[test]
fn codabar_as_ascii() {
let codabar = Codabar::new("A98B".to_owned()).unwrap();
let codabar = Codabar::new("A98B").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&codabar.encode()[..]).unwrap();

Expand All @@ -198,12 +198,12 @@ mod tests {
# ## # # ## # # # # ## # # # # # ##
# ## # # ## # # # # ## # # # # # ##
# ## # # ## # # # # ## # # # # # ##
".trim().to_owned());
".trim());
}

#[test]
fn codabar_as_ascii_small_height_double_weight() {
let codabar = Codabar::new("A40156B".to_owned()).unwrap();
let codabar = Codabar::new("A40156B").unwrap();
let ascii = ASCII{height: 7, xdim: 2};
let generated = ascii.generate(&codabar.encode()[..]).unwrap();

Expand All @@ -216,12 +216,12 @@ mod tests {
## #### ## ## ## #### ## ## ## ## ## #### ## ## #### ## #### ## ## ## ## ## ## #### ## ## ## ####
## #### ## ## ## #### ## ## ## ## ## #### ## ## #### ## #### ## ## ## ## ## ## #### ## ## ## ####
## #### ## ## ## #### ## ## ## ## ## #### ## ## #### ## #### ## ## ## ## ## ## #### ## ## ## ####
".trim().to_owned());
".trim());
}

#[test]
fn code_128_as_ascii() {
let code128 = Code128::new("ÀHELLO".to_owned()).unwrap();
let code128 = Code128::new("ÀHELLO").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&code128.encode()[..]).unwrap();

Expand All @@ -237,12 +237,12 @@ mod tests {
## # # ## # # # ## # # ## ### # ## ### # ### ## ## # # ## ### # ##
## # # ## # # # ## # # ## ### # ## ### # ### ## ## # # ## ### # ##
## # # ## # # # ## # # ## ### # ## ### # ### ## ## # # ## ### # ##
".trim().to_owned());
".trim());
}

#[test]
fn code_128_as_ascii_small_height_double_weight() {
let code128 = Code128::new("ÀHELLO".to_owned()).unwrap();
let code128 = Code128::new("ÀHELLO").unwrap();
let ascii = ASCII{height: 7, xdim: 2};
let generated = ascii.generate(&code128.encode()[..]).unwrap();

Expand All @@ -255,12 +255,12 @@ mod tests {
#### ## ## #### ## ## ## #### ## ## #### ###### ## #### ###### ## ###### #### #### ## ## #### ###### ## ####
#### ## ## #### ## ## ## #### ## ## #### ###### ## #### ###### ## ###### #### #### ## ## #### ###### ## ####
#### ## ## #### ## ## ## #### ## ## #### ###### ## #### ###### ## ###### #### #### ## ## #### ###### ## ####
".trim().to_owned());
".trim());
}

#[test]
fn ean2_as_ascii() {
let ean2 = EANSUPP::new("34".to_owned()).unwrap();
let ean2 = EANSUPP::new("34").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&ean2.encode()[..]).unwrap();

Expand All @@ -276,12 +276,12 @@ mod tests {
# ## # # # # ##
# ## # # # # ##
# ## # # # # ##
".trim().to_owned());
".trim());
}

#[test]
fn ean5_as_ascii() {
let ean5 = EANSUPP::new("50799".to_owned()).unwrap();
let ean5 = EANSUPP::new("50799").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&ean5.encode()[..]).unwrap();

Expand All @@ -297,12 +297,12 @@ mod tests {
# ## ## # # # ### # # # # # ## # # ##
# ## ## # # # ### # # # # # ## # # ##
# ## ## # # # ### # # # # # ## # # ##
".trim().to_owned());
".trim());
}

#[test]
fn itf_as_ascii() {
let itf = TF::interleaved("12345".to_owned()).unwrap();
let itf = TF::interleaved("12345").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&itf.encode()[..]).unwrap();

Expand All @@ -318,12 +318,12 @@ mod tests {
# # ### # # # ### ### ### # # # ### # ### # # ## #
# # ### # # # ### ### ### # # # ### # ### # # ## #
# # ### # # # ### ### ### # # # ### # ### # # ## #
".trim().to_owned());
".trim());
}

#[test]
fn code_93_as_ascii() {
let code93 = Code93::new("TEST93".to_owned()).unwrap();
let code93 = Code93::new("TEST93").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&code93.encode()[..]).unwrap();

Expand All @@ -339,12 +339,12 @@ mod tests {
# # #### ## # ## ## # # ## # ## ## # ## # # # # # # # ### ## # # # # # #### #
# # #### ## # ## ## # # ## # ## ## # ## # # # # # # # ### ## # # # # # #### #
# # #### ## # ## ## # # ## # ## ## # ## # # # # # # # ### ## # # # # # #### #
".trim().to_owned());
".trim());
}

#[test]
fn code_93_as_ascii_small_height_double_weight() {
let code93 = Code93::new("TEST93".to_owned()).unwrap();
let code93 = Code93::new("TEST93").unwrap();
let ascii = ASCII{height: 7, xdim: 2};
let generated = ascii.generate(&code93.encode()[..]).unwrap();

Expand All @@ -357,12 +357,12 @@ mod tests {
## ## ######## #### ## #### #### ## ## #### ## #### #### ## #### ## ## ## ## ## ## ## ###### #### ## ## ## ## ## ######## ##
## ## ######## #### ## #### #### ## ## #### ## #### #### ## #### ## ## ## ## ## ## ## ###### #### ## ## ## ## ## ######## ##
## ## ######## #### ## #### #### ## ## #### ## #### #### ## #### ## ## ## ## ## ## ## ###### #### ## ## ## ## ## ######## ##
".trim().to_owned());
".trim());
}

#[test]
fn code_11_as_ascii() {
let code11 = Code11::new("12-9".to_owned()).unwrap();
let code11 = Code11::new("12-9").unwrap();
let ascii = ASCII::new();
let generated = ascii.generate(&code11.encode()[..]).unwrap();

Expand All @@ -378,6 +378,6 @@ mod tests {
# ## # ## # ## # # ## # ## # ## # # # ## # # ## #
# ## # ## # ## # # ## # ## # ## # # # ## # # ## #
# ## # ## # ## # # ## # ## # ## # # # ## # # ## #
".trim().to_owned());
".trim());
}
}

0 comments on commit 5efb6ed

Please sign in to comment.