Skip to content

Commit f373645

Browse files
committed
update project
1 parent 21ae3cc commit f373645

File tree

7 files changed

+5
-141
lines changed

7 files changed

+5
-141
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
toolchain: nightly
2929
override: true
3030
components: clippy
31-
- run: cargo clippy -- -D warnings
31+
- run: cargo clippy --all-targets --all-features -- -D warnings
3232

3333
tests:
3434
strategy:

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "byte-unit"
3-
version = "4.0.13"
3+
version = "4.0.14"
44
authors = ["Magic Len <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66
repository = "https://github.com/magiclen/byte-unit"
77
homepage = "https://magiclen.org/byte-unit"
88
keywords = ["byte", "unit", "kb", "mb", "gb"]

README.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,15 @@ The data type for storing the size of bytes is `u128` by default, but can also b
1414
There are `n_*_bytes` macros can be used. The star `*` means the unit. For example, `n_gb_bytes` can be used to get a **n-GB** value in bytes.
1515

1616
```rust
17-
#[macro_use] extern crate byte_unit;
18-
19-
let result = n_gb_bytes!(4);
17+
let result = byte_unit::n_gb_bytes!(4);
2018

2119
assert_eq!(4000000000, result);
2220
```
2321

2422
You may need to assign a primitive type if the `n` is not an integer.
2523

2624
```rust
27-
#[macro_use] extern crate byte_unit;
28-
29-
let result = n_gb_bytes!(2.5, f64);
25+
let result = byte_unit::n_gb_bytes!(2.5, f64);
3026

3127
assert_eq!(2500000000, result);
3228
```
@@ -38,8 +34,6 @@ The `Byte` structure can be used for representing a size of bytes.
3834
The `from_str` associated function can parse any **SIZE** string and return a `Byte` instance in common usage. The format of a **SIZE** string is like "123", "123KiB" or "50.84 MB".
3935

4036
```rust
41-
extern crate byte_unit;
42-
4337
use byte_unit::Byte;
4438

4539
let result = Byte::from_str("50.84 MB").unwrap();
@@ -50,8 +44,6 @@ assert_eq!(50840000, result.get_bytes());
5044
You can also use the `from_bytes` and `from_unit` associated functions to create a `Byte` instance.
5145

5246
```rust
53-
extern crate byte_unit;
54-
5547
use byte_unit::Byte;
5648

5749
let result = Byte::from_bytes(1500000);
@@ -60,8 +52,6 @@ assert_eq!(1500000, result.get_bytes());
6052
```
6153

6254
```rust
63-
extern crate byte_unit;
64-
6555
use byte_unit::{Byte, ByteUnit};
6656

6757
let result = Byte::from_unit(1500f64, ByteUnit::KB).unwrap();
@@ -74,8 +64,6 @@ assert_eq!(1500000, result.get_bytes());
7464
To change the unit of a `Byte` instance, you can use the `get_adjusted_unit` method.
7565

7666
```rust
77-
extern crate byte_unit;
78-
7967
use byte_unit::{Byte, ByteUnit};
8068

8169
let byte = Byte::from_str("123KiB").unwrap();
@@ -88,8 +76,6 @@ assert_eq!("125.95 KB", adjusted_byte.to_string());
8876
To change the unit of a `Byte` instance automatically and appropriately, you can use the `get_appropriate_unit` method.
8977

9078
```rust
91-
extern crate byte_unit;
92-
9379
use byte_unit::Byte;
9480

9581
let byte = Byte::from_bytes(1500000);
@@ -100,8 +86,6 @@ assert_eq!("1.50 MB", adjusted_byte.to_string());
10086
```
10187

10288
```rust
103-
extern crate byte_unit;
104-
10589
use byte_unit::Byte;
10690

10791
let byte = Byte::from_bytes(1500000);
@@ -116,8 +100,6 @@ The number of fractional digits created by the `to_string` method of a `Adjusted
116100
To change the number of fractional digits in the formatted string, you can use the `format` method instead.
117101

118102
```rust
119-
extern crate byte_unit;
120-
121103
use byte_unit::Byte;
122104

123105
let byte = Byte::from_bytes(1500000);

src/adjusted_byte.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ impl AdjustedByte {
2424
/// # Examples
2525
///
2626
/// ```
27-
/// extern crate byte_unit;
28-
///
2927
/// use byte_unit::{Byte, ByteUnit};
3028
///
3129
/// let byte = Byte::from_unit(1555f64, ByteUnit::KB).unwrap();
@@ -36,8 +34,6 @@ impl AdjustedByte {
3634
/// ```
3735
///
3836
/// ```
39-
/// extern crate byte_unit;
40-
///
4137
/// use byte_unit::{Byte, ByteUnit};
4238
///
4339
/// let byte = Byte::from_unit(1555.2f64, ByteUnit::B).unwrap();
@@ -70,8 +66,6 @@ impl AdjustedByte {
7066
/// ## Examples
7167
///
7268
/// ```
73-
/// extern crate byte_unit;
74-
///
7569
/// use byte_unit::{Byte, ByteUnit};
7670
///
7771
/// let byte = Byte::from_str("123456789123456").unwrap();
@@ -111,8 +105,6 @@ impl PartialEq for AdjustedByte {
111105
/// # Examples
112106
///
113107
/// ```
114-
/// extern crate byte_unit;
115-
///
116108
/// use byte_unit::{Byte, ByteUnit};
117109
///
118110
/// let byte1 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();
@@ -122,8 +114,6 @@ impl PartialEq for AdjustedByte {
122114
/// ```
123115
///
124116
/// ```
125-
/// extern crate byte_unit;
126-
///
127117
/// use byte_unit::{Byte, ByteUnit};
128118
///
129119
/// let byte1 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();
@@ -158,8 +148,6 @@ impl Ord for AdjustedByte {
158148
/// # Examples
159149
///
160150
/// ```
161-
/// extern crate byte_unit;
162-
///
163151
/// use byte_unit::{Byte, ByteUnit};
164152
///
165153
/// let byte1 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();
@@ -169,8 +157,6 @@ impl Ord for AdjustedByte {
169157
/// ```
170158
///
171159
/// ```
172-
/// extern crate byte_unit;
173-
///
174160
/// use byte_unit::{Byte, ByteUnit};
175161
///
176162
/// let byte1 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();

src/byte.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ impl Byte {
3232
/// ## Examples
3333
///
3434
/// ```
35-
/// extern crate byte_unit;
36-
///
3735
/// use byte_unit::{Byte, ByteUnit};
3836
///
3937
/// let result = Byte::from_unit(1500f64, ByteUnit::KB).unwrap();
@@ -56,8 +54,6 @@ impl Byte {
5654
/// ## Examples
5755
///
5856
/// ```
59-
/// extern crate byte_unit;
60-
///
6157
/// use byte_unit::{Byte, ByteUnit};
6258
///
6359
/// let result = Byte::from_bytes(1500000);
@@ -75,8 +71,6 @@ impl Byte {
7571
/// ## Examples
7672
///
7773
/// ```
78-
/// extern crate byte_unit;
79-
///
8074
/// use byte_unit::{Byte, ByteUnit};
8175
///
8276
/// let result = Byte::from_bytes(1500000);
@@ -94,8 +88,6 @@ impl Byte {
9488
/// ## Examples
9589
///
9690
/// ```
97-
/// extern crate byte_unit;
98-
///
9991
/// use byte_unit::{Byte, ByteUnit};
10092
///
10193
/// let result = Byte::from_str("123KiB").unwrap();
@@ -104,8 +96,6 @@ impl Byte {
10496
/// ```
10597
///
10698
/// ```
107-
/// extern crate byte_unit;
108-
///
10999
/// use byte_unit::{Byte, ByteUnit};
110100
///
111101
/// let result = Byte::from_str("50.84 MB").unwrap();
@@ -114,8 +104,6 @@ impl Byte {
114104
/// ```
115105
///
116106
/// ```
117-
/// extern crate byte_unit;
118-
///
119107
/// use byte_unit::{Byte, ByteUnit};
120108
///
121109
/// let result = Byte::from_str("8 B").unwrap(); // 8 bytes
@@ -124,8 +112,6 @@ impl Byte {
124112
/// ```
125113
///
126114
/// ```
127-
/// extern crate byte_unit;
128-
///
129115
/// use byte_unit::{Byte, ByteUnit};
130116
///
131117
/// let result = Byte::from_str("8").unwrap(); // 8 bytes
@@ -134,8 +120,6 @@ impl Byte {
134120
/// ```
135121
///
136122
/// ```
137-
/// extern crate byte_unit;
138-
///
139123
/// use byte_unit::{Byte, ByteUnit};
140124
///
141125
/// let result = Byte::from_str("8 b").unwrap(); // 8 bytes
@@ -144,8 +128,6 @@ impl Byte {
144128
/// ```
145129
///
146130
/// ```
147-
/// extern crate byte_unit;
148-
///
149131
/// use byte_unit::{Byte, ByteUnit};
150132
///
151133
/// let result = Byte::from_str("8 kb").unwrap(); // 8 kilobytes
@@ -154,8 +136,6 @@ impl Byte {
154136
/// ```
155137
///
156138
/// ```
157-
/// extern crate byte_unit;
158-
///
159139
/// use byte_unit::{Byte, ByteUnit};
160140
///
161141
/// let result = Byte::from_str("8 kib").unwrap(); // 8 kibibytes
@@ -164,8 +144,6 @@ impl Byte {
164144
/// ```
165145
///
166146
/// ```
167-
/// extern crate byte_unit;
168-
///
169147
/// use byte_unit::{Byte, ByteUnit};
170148
///
171149
/// let result = Byte::from_str("8 k").unwrap(); // 8 kilobytes
@@ -286,8 +264,6 @@ impl Byte {
286264
/// ## Examples
287265
///
288266
/// ```
289-
/// extern crate byte_unit;
290-
///
291267
/// use byte_unit::Byte;
292268
///
293269
/// let byte = Byte::from_str("123KiB").unwrap();
@@ -298,8 +274,6 @@ impl Byte {
298274
/// ```
299275
///
300276
/// ```
301-
/// extern crate byte_unit;
302-
///
303277
/// use byte_unit::Byte;
304278
///
305279
/// let byte = Byte::from_str("50.84 MB").unwrap();
@@ -319,8 +293,6 @@ impl Byte {
319293
/// ## Examples
320294
///
321295
/// ```
322-
/// extern crate byte_unit;
323-
///
324296
/// use byte_unit::Byte;
325297
///
326298
/// let byte = Byte::from_str("123KiB").unwrap();
@@ -331,8 +303,6 @@ impl Byte {
331303
/// ```
332304
///
333305
/// ```
334-
/// extern crate byte_unit;
335-
///
336306
/// use byte_unit::Byte;
337307
///
338308
/// let byte = Byte::from_str("50.84 MB").unwrap();
@@ -352,8 +322,6 @@ impl Byte {
352322
/// ## Examples
353323
///
354324
/// ```
355-
/// extern crate byte_unit;
356-
///
357325
/// use byte_unit::{Byte, ByteUnit};
358326
///
359327
/// let byte = Byte::from_str("123KiB").unwrap();
@@ -364,8 +332,6 @@ impl Byte {
364332
/// ```
365333
///
366334
/// ```
367-
/// extern crate byte_unit;
368-
///
369335
/// use byte_unit::{Byte, ByteUnit};
370336
///
371337
/// let byte = Byte::from_str("50.84 MB").unwrap();
@@ -391,8 +357,6 @@ impl Byte {
391357
/// ## Examples
392358
///
393359
/// ```
394-
/// extern crate byte_unit;
395-
///
396360
/// use byte_unit::Byte;
397361
///
398362
/// let byte = Byte::from_str("123KiB").unwrap();
@@ -403,8 +367,6 @@ impl Byte {
403367
/// ```
404368
///
405369
/// ```
406-
/// extern crate byte_unit;
407-
///
408370
/// use byte_unit::Byte;
409371
///
410372
/// let byte = Byte::from_str("50.84 MB").unwrap();

src/byte_unit.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate utf8_width;
2-
31
use core::convert::TryFrom;
42
use core::str::{from_utf8_unchecked, Bytes, FromStr};
53

@@ -59,8 +57,6 @@ impl ByteUnit {
5957
/// Get an instance of `ByteUnit` from a string slice.
6058
///
6159
/// ```
62-
/// extern crate byte_unit;
63-
///
6460
/// use byte_unit::ByteUnit;
6561
///
6662
/// assert_eq!(ByteUnit::B, ByteUnit::from_str("").unwrap());
@@ -90,8 +86,6 @@ impl ByteUnit {
9086
/// Use string slice to represent this `ByteUnit`.
9187
///
9288
/// ```
93-
/// extern crate byte_unit;
94-
///
9589
/// use byte_unit::ByteUnit;
9690
///
9791
/// assert_eq!("B", ByteUnit::B.as_str());
@@ -134,8 +128,6 @@ impl ByteUnit {
134128
/// Get bytes represented by this `ByteUnit`.
135129
///
136130
/// ```
137-
/// extern crate byte_unit;
138-
///
139131
/// use byte_unit::ByteUnit;
140132
///
141133
/// assert_eq!(1000000000000000000000, ByteUnit::ZB.get_unit_bytes());
@@ -166,8 +158,6 @@ impl ByteUnit {
166158
/// Get bytes represented by this `ByteUnit`.
167159
///
168160
/// ```
169-
/// extern crate byte_unit;
170-
///
171161
/// use byte_unit::ByteUnit;
172162
///
173163
/// assert_eq!(1024, ByteUnit::KiB.get_unit_bytes());

0 commit comments

Comments
 (0)