Skip to content

Commit

Permalink
Merge pull request #58 from cloud-oak/typed_iterator
Browse files Browse the repository at this point in the history
Make ProgressBar a parametric type
  • Loading branch information
khdlr authored Sep 30, 2024
2 parents dc84f79 + 193a51d commit 8d798ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
- os: macos-latest
julia-version: '1.6'
julia-arch: ''
- os: windows-latest
julia-version: '1.6'
include:
- os: macos-latest
julia-version: '1.6'
Expand Down
11 changes: 6 additions & 5 deletions src/ProgressBars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module ProgressBars
using Printf
using Base.Threads


EIGHTS = Dict(0 => ' ',
1 => '',
2 => '',
Expand All @@ -31,8 +32,8 @@ Decorate an iterable object, returning an iterator which acts exactly
like the original iterable, but prints a dynamically updating
progressbar every time a value is requested.
"""
mutable struct ProgressBar
wrapped::Any
mutable struct ProgressBar{T}
wrapped::T
total::Int64
current::Int64
current_printed::Int64
Expand All @@ -54,15 +55,15 @@ mutable struct ProgressBar
print_lock::Threads.ReentrantLock
output_stream::IO

function ProgressBar(wrapped::Any=nothing;
function ProgressBar(wrapped::T=nothing;
total::Int64=-2,
width::Union{UInt, Nothing}=nothing,
leave::Bool=true,
unit::AbstractString="",
unit_scale::Bool=true,
printing_delay::Number=0.05,
output_stream::IO=stderr)
this = new()
output_stream::IO=stderr) where T
this = new{T}()
this.wrapped = wrapped
if width == nothing
this.width = displaysize(output_stream)[2]
Expand Down

0 comments on commit 8d798ff

Please sign in to comment.