rafaqz / Interfaces.jl

Macros to define and implement interfaces, to ensure they are checked and correct.
MIT License
72 stars 4 forks source link

add singleton traits #15

Closed rafaqz closed 9 months ago

rafaqz commented 9 months ago

This PR adds Implemented{T} and NotImplemented{T} traits for use in dispatch, as an alternative to the true/false return values of implements.

Bikeshedding on what to call the function requested, implemented_trait isn't amazing.

Also realised we were not accepting objects, just types, and that really doesn't make sense for traits. So now we accept and test that passing objects to implements and implemented_trait works.

@gdalle if you want to review that would help

codecov-commenter commented 9 months ago

Codecov Report

Merging #15 (d266d0a) into main (f52e483) will increase coverage by 1.40%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #15      +/-   ##
==========================================
+ Coverage   77.35%   78.76%   +1.40%     
==========================================
  Files           4        4              
  Lines         106      113       +7     
==========================================
+ Hits           82       89       +7     
  Misses         24       24              
Files Coverage Δ
src/implements.jl 86.95% <100.00%> (+5.70%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more