@@ -231,67 +231,72 @@ extension View {
231231 ///
232232 /// **Example**: `.applyIf(colorScheme == .dark) { $0.shadow(color: Color(white: 0.88), radius: 40, x: 0, y: 10) } else: { $0.foregroundColor(.white) }`
233233 @inlinable
234+ @ViewBuilder
234235 public func applyIf< M: View , A: View > (
235236 _ condition: Bool ,
236237 modifier: ( Self ) -> M ,
237238 else alternativeModifier: ( Self ) -> A
238239 ) -> some View {
239240 if condition {
240- return modifier ( self ) . eraseToAnyView ( )
241+ modifier ( self )
241242 } else {
242- return alternativeModifier ( self ) . eraseToAnyView ( )
243+ alternativeModifier ( self )
243244 }
244245 }
245246
246247 /// A wrapper for a view modifier that only applies if the given condition is met.
247248 ///
248249 /// **Example**: `.applyIf(colorScheme == .dark) { $0.shadow(color: Color(white: 0.88), radius: 40, x: 0, y: 10) }`
249250 @inlinable
251+ @ViewBuilder
250252 public func applyIf< ModifiedView: View > ( _ condition: Bool , modifier: ( Self ) -> ModifiedView ) -> some View {
251253 if condition {
252- return modifier ( self ) . eraseToAnyView ( )
254+ modifier ( self )
253255 } else {
254- return self . eraseToAnyView ( )
256+ self
255257 }
256258 }
257259
258260 /// A wrapper for a view modifier that only applies if the given condition is **not** met.
259261 ///
260262 /// **Example**: `.applyIfNot(colorScheme == .dark) { $0.shadow(color: Color(white: 0.88), radius: 40, x: 0, y: 10) }`
261263 @inlinable
264+ @ViewBuilder
262265 public func applyIfNot< ModifiedView: View > ( _ condition: Bool , modifier: ( Self ) -> ModifiedView ) -> some View {
263266 if !condition {
264- return modifier ( self ) . eraseToAnyView ( )
267+ modifier ( self )
265268 } else {
266- return self . eraseToAnyView ( )
269+ self
267270 }
268271 }
269272
270273 /// A wrapper for a view modifier that only applies if the given optional value is not `nil` and passes the unwrapped value as its second parameter.
271274 ///
272275 /// **Example**: `.ifLet(self.shadowColor) { $0.shadow(color: $1, radius: 40, x: 0, y: 10) }`
273276 @inlinable
277+ @ViewBuilder
274278 public func ifLet< T, ModifiedView: View > ( _ optionalValue: T ? , modifier: ( Self , T ) -> ModifiedView ) -> some View {
275279 if let optionalValue {
276- return modifier ( self , optionalValue) . eraseToAnyView ( )
280+ modifier ( self , optionalValue)
277281 } else {
278- return self . eraseToAnyView ( )
282+ self
279283 }
280284 }
281285
282286 /// A wrapper for a view modifier that only applies if the given optional value is not `nil` and passes the unwrapped value as its second parameter.
283287 ///
284288 /// **Example**: `.ifLet(self.shadowColor) { $0.shadow(color: $1, radius: 40, x: 0, y: 10) } else: { $0.clipShape(.rect(cornerRadius: 15)) }`
285289 @inlinable
290+ @ViewBuilder
286291 public func ifLet< T, ModifiedView: View , ElseView: View > (
287292 _ optionalValue: T ? ,
288293 modifier: ( Self , T ) -> ModifiedView ,
289294 else elseModifier: ( Self ) -> ElseView
290295 ) -> some View {
291296 if let optionalValue {
292- return modifier ( self , optionalValue) . eraseToAnyView ( )
297+ modifier ( self , optionalValue)
293298 } else {
294- return elseModifier ( self ) . eraseToAnyView ( )
299+ elseModifier ( self )
295300 }
296301 }
297302
0 commit comments