This commit is contained in:
zest
2026-03-24 19:40:06 +08:00
2 changed files with 22 additions and 6 deletions

View File

@@ -157,9 +157,18 @@ extension Drawable {
extension Collection { extension Collection {
func chunked(into size: Int) -> [[Element]] { func chunked(into size: Int) -> [[Element]] {
stride(from: 0, to: count, by: size).map { guard size > 0 else { return [] }
Array(self[$0..<Swift.min($0 + size, count)])
var result: [[Element]] = []
var i = startIndex
while i != endIndex {
let j = index(i, offsetBy: size, limitedBy: endIndex) ?? endIndex
result.append(Array(self[i..<j]))
i = j
} }
return result
} }
} }
``` ```
@@ -216,7 +225,8 @@ struct Point {
### 4.2 Use Classes When Needed ### 4.2 Use Classes When Needed
Use classes for shared mutable state, identity matters: Use classes when identity, shared ownership, or reference semantics matter.
Prefer actors for mutable state shared across concurrent tasks:
```swift ```swift
class NetworkManager { class NetworkManager {
@@ -271,6 +281,9 @@ class Person {
### 5.2 Closure Capture Lists ### 5.2 Closure Capture Lists
Use capture lists intentionally to avoid retain cycles.
Choose `weak` or `unowned` based on lifetime guarantees:
```swift ```swift
// Weak capture for optional self // Weak capture for optional self
onComplete = { [weak self] in onComplete = { [weak self] in
@@ -385,6 +398,8 @@ func perform<T>(_ operation: () throws -> T) rethrows -> T {
**Impact:** CRITICAL **Impact:** CRITICAL
Use actor isolation and `Sendable` to prevent data races across concurrency domains.
### 7.1 Async Functions ### 7.1 Async Functions
```swift ```swift
@@ -715,13 +730,14 @@ UIView.animate(withDuration: 0.3) {
- [ ] No implicitly unwrapped optionals (`!`) in data models - [ ] No implicitly unwrapped optionals (`!`) in data models
### Memory ### Memory
- [ ] Closures use `[weak self]` when capturing self in escaping closures - [ ] Escaping closures capture `self` intentionally; use `[weak self]` or `[unowned self]` to avoid retain cycles when needed
- [ ] Delegate properties are `weak` - [ ] Delegate properties are `weak`
- [ ] No retain cycles between objects - [ ] No retain cycles between objects
### Concurrency ### Concurrency
- [ ] Async functions used instead of completion handlers - [ ] Async functions used instead of completion handlers
- [ ] Actors protect shared mutable state - [ ] Mutable state shared across concurrency domains is isolated, often with actors
- [ ] Types crossing concurrency domains use `Sendable` when appropriate
- [ ] UI updates on `@MainActor` - [ ] UI updates on `@MainActor`
- [ ] Task cancellation checked in long operations - [ ] Task cancellation checked in long operations

View File

@@ -1,6 +1,6 @@
--- ---
name: minimax-xlsx name: minimax-xlsx
description: Open, create, read, analyze, edit, or validate Excel/spreadsheet files (.xlsx, .xlsm, .csv, .tsv). Use when the user asks to create, build, modify, analyze, read, validate, or format any Excel spreadsheet, financial model, pivot table, or tabular data file. Covers: creating new xlsx from scratch, reading and analyzing existing files, editing existing xlsx with zero format loss, formula recalculation and validation, and applying professional financial formatting standards. Triggers on 'spreadsheet', 'Excel', '.xlsx', '.csv', 'pivot table', 'financial model', 'formula', or any request to produce tabular data in Excel format. description: "Open, create, read, analyze, edit, or validate Excel/spreadsheet files (.xlsx, .xlsm, .csv, .tsv). Use when the user asks to create, build, modify, analyze, read, validate, or format any Excel spreadsheet, financial model, pivot table, or tabular data file. Covers: creating new xlsx from scratch, reading and analyzing existing files, editing existing xlsx with zero format loss, formula recalculation and validation, and applying professional financial formatting standards. Triggers on 'spreadsheet', 'Excel', '.xlsx', '.csv', 'pivot table', 'financial model', 'formula', or any request to produce tabular data in Excel format."
license: MIT license: MIT
metadata: metadata:
version: "1.0" version: "1.0"