Skip to content

Conversation

guykogus
Copy link
Contributor

πŸš€
The underlying function is generic, so might as well do the same.

Checklist

  • I checked the Contributing Guidelines before creating this request.
  • New extensions are written in Swift 5.0.
  • New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
  • I have added tests for new extensions, and they passed.
  • All extensions have a clear comments explaining their functionality, all parameters and return type in English.
  • All extensions are declared as public.
  • I have added a changelog entry describing my changes.

@guykogus guykogus requested a review from LucianoPAlmeida July 21, 2020 09:30
@codecov
Copy link

codecov bot commented Jul 21, 2020

Codecov Report

Merging #880 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #880      +/-   ##
==========================================
- Coverage   92.85%   92.84%   -0.01%     
==========================================
  Files         100      100              
  Lines        3427     3424       -3     
==========================================
- Hits         3182     3179       -3     
  Misses        245      245              
Flag Coverage Ξ”
#ios 95.60% <100.00%> (-0.01%) ⬇️
#macos 82.93% <100.00%> (-0.03%) ⬇️
#tvos 93.59% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Ξ”
...es/SwifterSwift/SwiftStdlib/DoubleExtensions.swift 100.00% <ΓΈ> (ΓΈ)
...ces/SwifterSwift/SwiftStdlib/FloatExtensions.swift 100.00% <ΓΈ> (ΓΈ)
...terSwift/SwiftStdlib/FloatingPointExtensions.swift 100.00% <100.00%> (ΓΈ)

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 59522d7...b909080. Read the comment docs.

@SwifterSwiftBot
Copy link

4 Messages
πŸ“– Thank you for submitting a pull request to SwifterSwift. The team will review your submission as soon as possible.
πŸ“– iOS: Executed 687 tests, with 0 failures (0 unexpected) in 24.763 (25.950) seconds
πŸ“– tvOS: Executed 649 tests, with 0 failures (0 unexpected) in 4.072 (4.514) seconds
πŸ“– macOS: Executed 512 tests, with 0 failures (0 unexpected) in 5.540 (5.710) seconds

Generated by 🚫 Danger

@@ -81,3 +81,15 @@ public prefix func Β± <T: FloatingPoint> (number: T) -> (T, T) {
return 0 Β± number
}
// swiftlint:enable identifier_name

// swiftlint:disable identifier_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be a good thing to add those exceptions on the swiftlint.yaml file ... common cases like those to avoid this bunch of enable disable ... no in this PR though, might be good for an issue with starter task :)

///
/// - Parameter float: float value to find square root for
/// - Returns: square root of given float.
public prefix func √<T> (float: T) -> T where T: FloatingPoint {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if its time to think about inline such trivial numeric operators like this, the implementation is trivial so maybe we should throw an @inlinable here (and possibly audit other places where we could do it as well). This is good especially for generic functions like this one because it would allow the compiler to specialize such functions on clients that install this library as a module.

Copy link
Member

@LucianoPAlmeida LucianoPAlmeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the comments are for think in followup PRs, so this LGTM!

@guykogus guykogus merged commit 262c8d7 into master Jul 21, 2020
@guykogus guykogus deleted the sqrt branch July 21, 2020 13:47
nasircsms pushed a commit to nasircsms/SwifterSwift that referenced this pull request Aug 26, 2020
* 'master' of https://github.com/SwifterSwift/SwifterSwift: (79 commits)
  Helper functions for scrolling to the edges or by page of a scroll view (SwifterSwift#888)
  Add XCTest extension for comparing Color objects (SwifterSwift#889)
  Fix swiftlint error (SwifterSwift#894)
  Bump kramdown from 2.1.0 to 2.3.0 (SwifterSwift#891)
  Added note for UIView.addShadow() (SwifterSwift#890)
  loadFromNib(withClass) (SwifterSwift#885)
  constraint finders (widthConstraint, heightConstraint, leadingConstraint, trailingConstraint, topConstraint, bottomConstraint) (SwifterSwift#886)
  added String.regexEscaped (SwifterSwift#883)
  Make √ generic for FloatingPoint values (SwifterSwift#880)
  Update UITextField extensions (SwifterSwift#878)
  Added `masksToBounds` (IBInspectable) extension (SwifterSwift#877)
  Reinstate debounce function (SwifterSwift#869)
  `RandomAccessCollection`/`Collection` generalisations (SwifterSwift#863)
  Added HKActivitySummary extensions (SwifterSwift#875)
  Added new method for easily instantiating a view controller from a storyboard (SwifterSwift#860)
  Clean up code (SwifterSwift#864)
  fixed "".truncated crashed (SwifterSwift#866)
  Deprecated map(by:), compactMap(by:), filter(by:) (SwifterSwift#862)
  Overloaded 'contains' operator for string regex matching (SwifterSwift#858)
  Added convenient wrapper to asyncAfter (SwifterSwift#859)
  ...

# Conflicts:
#	Sources/SwifterSwift/AppKit/NSColorExtensions.swift
#	Sources/SwifterSwift/AppKit/NSImageExtensions.swift
#	Sources/SwifterSwift/AppKit/NSViewExtensions.swift
#	Sources/SwifterSwift/CoreGraphics/CGColorExtensions.swift
#	Sources/SwifterSwift/CoreGraphics/CGFloatExtensions.swift
#	Sources/SwifterSwift/CoreGraphics/CGPointExtensions.swift
#	Sources/SwifterSwift/CoreGraphics/CGSizeExtensions.swift
#	Sources/SwifterSwift/Foundation/NSAttributedStringExtensions.swift
#	Sources/SwifterSwift/SwiftStdlib/StringExtensions.swift
#	SwifterSwift.xcodeproj/project.pbxproj
#	Tests/AppKitTests/NSColorExtensionsTests.swift
#	Tests/SwiftStdlibTests/StringExtensionsTests.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants