GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - yewstack/implicit-clone: Immutable types and ImplicitClone trait similar to Copy

BranchesTags
Open more actions menu

Latest commit

 

History

96 Commits
96 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
benches
benches
 
 
implicit-clone-derive
implicit-clone-derive
 
 
src
src
 
 
.gitignore
.gitignore
 
 
Cargo.toml
Cargo.toml
 
 
README.md
README.md
 
 

Repository files navigation

Rust Latest Version License Docs.rs LOC Dependency Status

ImplicitClone

This library introduces the marker trait ImplicitClone intended for cheap-to-clone types that should be allowed to be cloned implicitly. It enables host libraries using this crate to have the syntax of Copy while actually calling the Clone implementation instead (usually when host library does such syntax in a macro).

The idea is that you must implement this trait on your cheap-to-clone types, and then the host library using the trait will allow users to pass values of your types and they will be cloned automatically.

Standard types that the ImplicitClone is already implemented for:

  • std::rc::Rc
  • std::sync::Arc
  • Tuples with 1-12 elements, all of which are also ImplicitClone
  • Option, where inner value is ImplicitClone
  • Some built-in Copy types, like (), bool, &T, etc.

This crate is in the category rust-patterns but this is actually a Rust anti-pattern. In Rust the user should always handle borrowing and ownership by themselves. Nevertheless, this pattern is sometimes desirable. For example, UI frameworks that rely on propagating properties from ancestors to multiple children will always need to use Rc'd types to cheaply and concisely update every child component. This is the case in React-like frameworks like Yew.

This crate also provides a few convenient immutable types for handling cheap-to-clone strings, arrays and maps, you can find them in the modules sync and unsync. Those types implement ImplicitClone and hold only types that implement ImplicitClone as well. One big particularity: iterating on these types yields clones of the items and not references. This can be particularly handy when using a React-like framework.

About

Immutable types and ImplicitClone trait similar to Copy

Topics

cheap-clonecopyimmutablerc

Resources

Readme
Activity
Custom properties

Stars

23 stars

Watchers

5 watching

Forks

12 forks
Report repository

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.