Skip to content

Commit

Permalink
Make ProgressBar a parametric type
Browse files Browse the repository at this point in the history
  • Loading branch information
khdlr committed Sep 30, 2024
1 parent 36f382f commit 58fe4b1
Showing 1 changed file with 6 additions and 5 deletions.
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 58fe4b1

Please sign in to comment.