Skip to content

Commit 214c246

Browse files
committed
Support initializing Attribute with rule and initial value
1 parent 65a976c commit 214c246

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sources/OpenGraph/Attribute/Attribute/Attribute.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,27 @@ extension Attribute {
223223
}
224224
}
225225

226+
public init<R: Rule>(_ rule: R, initialValue: Value) where R.Value == Value {
227+
self = withUnsafePointer(to: rule) { pointer in
228+
withUnsafePointer(to: initialValue) { initialValuePointer in
229+
Attribute(body: pointer, value: initialValuePointer) { R._update }
230+
}
231+
}
232+
}
233+
226234
public init<R: StatefulRule>(_ rule: R) where R.Value == Value {
227235
self = withUnsafePointer(to: rule) { pointer in
228236
Attribute(body: pointer, value: nil) { R._update }
229237
}
230238
}
239+
240+
public init<R: StatefulRule>(_ rule: R, initialValue: Value) where R.Value == Value {
241+
self = withUnsafePointer(to: rule) { pointer in
242+
withUnsafePointer(to: initialValue) { initialValuePointer in
243+
Attribute(body: pointer, value: initialValuePointer) { R._update }
244+
}
245+
}
246+
}
231247
}
232248

233249
@_silgen_name("OGGraphCreateAttribute")

0 commit comments

Comments
 (0)