bytesize icon indicating copy to clipboard operation
bytesize copied to clipboard

Example in documentation is out of date

Open wezm opened this issue 5 years ago • 2 comments

https://github.com/hyunsik/bytesize/pull/11 removed the implementation of Sub for ByteSize as well as the as_usize method. The example in the documentation tries to use both:

https://github.com/hyunsik/bytesize/blob/9d8e13f05fe2fb2596a5534e86ef135af5bae6a3/src/lib.rs#L18

Trying to run this example results in:

error[E0599]: no method named `as_usize` found for type `bytesize::ByteSize` in the current scope
 --> src/main.rs:8:27
  |
8 |   print!("{} bytes", plus.as_usize());
  |                           ^^^^^^^^

error[E0369]: binary operation `-` cannot be applied to type `bytesize::ByteSize`
  --> src/main.rs:10:15
   |
10 |   let minus = ByteSize::tb(100) - ByteSize::gb(4);
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: an implementation of `std::ops::Sub` might be missing for `bytesize::ByteSize`

wezm avatar Jan 05 '19 22:01 wezm

Will be fixed in f16ba51056fcf370548c661f35fe523fa6e03d59 of #15.

wookietreiber avatar Jan 06 '19 02:01 wookietreiber

I am still getting the subtraction error. Also, the readme says let minus = ByteSize::tb(100) + ByteSize::gb(4);. Shouldn't this be a -?

MarcelRobitaille avatar Feb 11 '21 20:02 MarcelRobitaille