In current implementation, a StaticRc<T, NUM, DEN> where NUM < DEN, it will do nothing on Drop. It can probably lead to memory leak if a "full" pointer is split up to two, and the two pointers are dropped silently.
How about to design the StaticRc<T, NUM, DEN> to be a linear type (i.e., it must be use and only use once). To say an object is fully used in the static reference counting system means: it is created as a full pointer like Box, and might be split up to several sub-pointers that shares the ownity, but must finally joined into a full pointer again, then the pointer is automatically dropped.
So the main implementation idea is: if I drop a non-full pointer, there will be a compile-time error because it is the object is not fully used.
In current implementation, a
StaticRc<T, NUM, DEN>whereNUM<DEN, it will do nothing onDrop. It can probably lead to memory leak if a "full" pointer is split up to two, and the two pointers are dropped silently.How about to design the
StaticRc<T, NUM, DEN>to be a linear type (i.e., it must be use and only use once). To say an object is fully used in the static reference counting system means: it is created as a full pointer likeBox, and might be split up to several sub-pointers that shares the ownity, but must finally joined into a full pointer again, then the pointer is automatically dropped.So the main implementation idea is: if I drop a non-full pointer, there will be a compile-time error because it is the object is not fully used.