Traits de Marcador
How does Rust know to forbid shared access across threads? The answer is in two traits:
Send: un tipoTesSendsi es seguro mover unTentre los límites de un hilo.Sync: un tipoTesSyncsi es seguro mover un&Tentre los límites de un hilo.
Send and Sync are unsafe traits. The compiler will automatically derive them for your types as long as they only contain Send and Sync types. You can also implement them manually when you know it is valid.
This slide should take about 2 minutes.
- Se podría pensar en estos traits como marcadores que indican que el tipo tiene ciertas propiedades de seguridad en hilos.
- Se pueden utilizar en las restricciones genéricas como traits normales.