Coder Social home page Coder Social logo

loading_bar's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @mendelsshop

  • Reach me by Mastodon Email

  • ๐Ÿ‘€ Iโ€™m interested in: Rust Python C

  • ๐ŸŒฑ Iโ€™m currently learning: Rust Python C Java

My Github stats:

badge
Top Langs
mendelsshop's GitHub stats

loading_bar's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

winksaville

loading_bar's Issues

Autorun index can be set to infinity

When using LoadingBar::auto_run you can set the length and start parameters to be the same. When the index is calculated in line 102 of src/lib.rs with let index = time_in_seconds as f32 / (len - start) as f32;, index while be set to inf because of division by 0. This will crash the program in this line:

line 112 src/lib.rs: self_clone.advance_by_print(start);

thread 'main' panicked at ' You can't advance more than the length of the bar', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/loading_bar-1.0.0/src/lib.rs:139:13

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I believe this is happening because the program tries to advance by the length of the bar which is larger than the length of the bar. And if the program kept going, the program it would then crash by trying to std::thread::sleep for inf seconds.

I guess it might be better to return a Result so you can tell the caller that they passed invalid parameters, and they can handle the errors themselves.

Auto Run possibly not working

While playing around with your library, I couldn't get auto_run to work although everything else did. I'm not sure whether this is just a problem with my computer or not. After looking more at your code for auto_run, I have a question. When you initialize a loading bar using:

let mut self_clone = LoadingBar {
    len,
    index: start,
    done: false,
    color,
    space_left: len - start,
    half: false,
    start_pos,
};

From my understanding, index keeps track of how far along the bar is, which is why you set it to start. But, on the next line you call

self_clone.advance_by_print(start);

which increments the index by start after it has already been set to start. I'm posting this issue as a question. Is this supposed to happen? Sorry to bother you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.