Skip to content

Added some extenisons#6

Open
ekucet wants to merge 4 commits intogokhanamal:mainfrom
ekucet:dev
Open

Added some extenisons#6
ekucet wants to merge 4 commits intogokhanamal:mainfrom
ekucet:dev

Conversation

@ekucet
Copy link

@ekucet ekucet commented Aug 27, 2025

Added some extensions

Added some extenisons
Copy link
Owner

@gokhanamal gokhanamal left a comment

Choose a reason for hiding this comment

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

Reviewed PR #6 ("Added some extenisons"). A few issues to address before merging:

  1. Doesn’t compile as-is: Optional+Ext.swift references EmptyValueRepresentable and ZeroValueRepresentable, but those protocols are not defined anywhere in the repo/PR. Either add them (with sensible defaults) or remove those extensions.

  2. Duplicate APIs for safe subscripting (Collection+Ext.swift):

    • subscript(safe:) and subscript(safeIndex:) do the same thing.
    • Suggest keeping a single API (prefer subscript(safe:)) and deleting the other.
  3. Library code should not print(): safeIndex prints an error on out-of-range access. This will spam logs in production apps. Prefer returning nil silently (or assert in DEBUG only).

  4. API surface / visibility:

    • Optional.boolValue is currently internal (no public). Decide if it should be public or keep it internal intentionally.
  5. Naming/typos + file headers:

    • PR title/commit message has typos (“extenisons”).
    • File headers say File.swift — consider renaming to match the file.

If you want, I can push a follow-up commit to this branch to address (2) and (3) quickly, but (1) needs a decision on whether you want those protocols in the public API.

@gokhanamal
Copy link
Owner

One more note: I’m an automated assistant/bot helping review this PR (not a human maintainer). Happy to help iterate.

@ekucet
Copy link
Author

ekucet commented Jan 30, 2026

Ok, thank you for your response. I fixed all of them.

@gokhanamal
Copy link
Owner

Follow-up review after the update (thanks for addressing the missing protocols / filenames):

✅ Fixed since last review:

  • Added missing EmptyValueRepresentable / ZeroValueRepresentable protocols
  • Renamed files + fixed some typos
  • Guarded the print with DEBUG
  • Made Optional.boolValue public

Remaining concerns / suggested tweaks before merge:

  1. Avoid importing UIKit in these extensions/protocols

    • EmptyValueRepresentable.swift and ZeroValueRepresentable.swift import UIKit mainly for UIEdgeInsets/CGRect/CGFloat.
    • This makes the entire package harder to build in non-UIKit contexts and is unnecessary for these core protocols.
      Suggested:
    • Use import Foundation + import CoreGraphics.
    • Only add UIKit-specific conformances under #if canImport(UIKit) with import UIKit inside that block.
  2. API choice for safe subscript

    • You removed subscript(safe:) and kept subscript(safeIndex:).
    • Most Swift libraries use subscript(safe:) as the conventional API.
      Suggest: rename safeIndex -> safe (or provide safe as the primary and keep safeIndex as deprecated alias).
  3. Logging

    • Even with DEBUG-guard, printing from a library is a bit noisy.
      Suggest: remove print entirely, or use assertionFailure in DEBUG.
  4. Semantics: String: ZeroValueRepresentable returning "0"

    • This is surprising: “zero” string usually implies empty string, not "0".
      Suggest: either remove String conformance from ZeroValueRepresentable, or set it to "" (and rely on EmptyValueRepresentable for empty).

If you want, I can propose a patch that:

  • moves UIKit-only conformances behind #if canImport(UIKit)
  • switches the safe subscript API to safe
  • replaces print with assertionFailure

@ekucet
Copy link
Author

ekucet commented Jan 31, 2026

Yes, I did changed and pushed. Thank you for your response.

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.

2 participants

Comments