Does 'assign(to:)' produce memory leaks?

Hello,

Indeed there is a retain cycle with the sample code that uses assign:

The Bar retains the AnyCancellable (1), which retains the Subscribers.Assign subscription (2), which retains the Bar (3) in order to be able to perform the assignment. Cycle completed: the Bar is never deinited.

Your other sample code captures self weakly. This avoids (3), breaks the cycle, and fixes the memory leak.