KristofferC / Crayons.jl

Colored and styled strings for terminals.
Other
150 stars 14 forks source link

Allow AbstractStrings #22

Closed oxinabox closed 6 years ago

oxinabox commented 6 years ago

I wanted to use a Crayon on a Regex capture. But it failed as those are SubStrings.

This is one way to fix it, by converting the inputs The other would be to change the Struct to allow Union{CrayonWrapper, AbstractStrings} which has problems of its own.

KristofferC commented 6 years ago
Error During Test at /home/travis/build/KristofferC/Crayons.jl/test/runtests.jl:135
  Test threw exception MethodError(convert, (Union{String, Crayons.CrayonWrapper}, String), 0x0000000000006afc)
  Expression: string((Crayon())("hello")) == "hello"
  MethodError: Cannot `convert` an object of type Type{String} to an object of type Union{String, Crayons.CrayonWrapper}
  Closest candidates are:
    convert(::Type{T}, !Matched::T) where T at essentials.jl:123
oxinabox commented 6 years ago

Well that was dumb of me. Good thing I also wrote a test to prove how good at stopping mid-sentence I am.

codecov-io commented 6 years ago

Codecov Report

Merging #22 into master will increase coverage by 0.04%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
+ Coverage   94.64%   94.69%   +0.04%     
==========================================
  Files           6        6              
  Lines         224      226       +2     
==========================================
+ Hits          212      214       +2     
  Misses         12       12
Impacted Files Coverage Δ
src/crayon_wrapper.jl 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f17f76c...505e45a. Read the comment docs.

oxinabox commented 6 years ago

I thought far too hard about String vs string

string(xs...)

Create a string from any values using the print function.

String(s::AbstractString)

Convert a string to a contiguous byte array representation encoded as UTF-8 bytes. This representation is often appropriate for passing strings to C.

KristofferC commented 6 years ago

Yeah, sorry, I deleted my comment straight away because I realized it should be string:)

oxinabox commented 6 years ago

Ah that would be why github went weird on me Cool, thanks

KristofferC commented 6 years ago

String I mean!