Research into nanostructured materials frequently relates to pure substances. This contrasts with industrial applications, where chemical doping or alloying is often used to enhance the electrical or mechanical properties of materials. However, the controlled preparation of doped nanomaterials has been much more difficult than expected because the increased surface-area-to-volume ratio can, for instance, lead to the expulsion of impurities (self-purification). For nanostructured alloys, the influence of growth methods and the atomic structure on self-purification is still open to investigation. Here, we explore, experimentally and with molecular dynamics simulations, to what extent alloying persists in the limit that a binary metal is mechanically stretched to a linear chain of atoms. Our results reveal a gradual evolution of the arrangement of the different atomic elements in the narrowest region of the chain, where impurities may be expelled to the surface or enclosed during elongation.