Add initializer without replace
This commit is contained in:
parent
75a4b9036e
commit
706806433f
@ -30,4 +30,20 @@ public struct AsyncFunctions<Element> {
|
|||||||
self.insert = insert
|
self.insert = insert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Initialize a functions value.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - delete: Delete the element at a certain index.
|
||||||
|
/// - insert: Insert a certain element at a certain index.
|
||||||
|
public init(
|
||||||
|
delete: @escaping (Int) async -> Void,
|
||||||
|
insert: @escaping (Int, Element) async -> Void
|
||||||
|
) {
|
||||||
|
self.replace = { index, element in
|
||||||
|
await delete(index)
|
||||||
|
await insert(index, element)
|
||||||
|
}
|
||||||
|
self.delete = delete
|
||||||
|
self.insert = insert
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,4 +30,20 @@ public struct Functions<Element> {
|
|||||||
self.insert = insert
|
self.insert = insert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Initialize a functions value.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - delete: Delete the element at a certain index.
|
||||||
|
/// - insert: Insert a certain element at a certain index.
|
||||||
|
public init(
|
||||||
|
delete: @escaping (Int) -> Void,
|
||||||
|
insert: @escaping (Int, Element) -> Void
|
||||||
|
) {
|
||||||
|
self.replace = { index, element in
|
||||||
|
delete(index)
|
||||||
|
insert(index, element)
|
||||||
|
}
|
||||||
|
self.delete = delete
|
||||||
|
self.insert = insert
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user