Definition of debt for equity swap

In the context of sovereign debt, when a creditor exchanges its loan to a country for an investment in one of that country's companies. In the context of corporate debt, when a creditor exchanges a loan to a company for a stake in that company's capital. This could be part of a debt restructuring.