Struct hydroflow_plus::builder::compiled::CompiledFlow
source · pub struct CompiledFlow<'a, ID> { /* private fields */ }
Implementations§
source§impl<ID> CompiledFlow<'_, ID>
impl<ID> CompiledFlow<'_, ID>
source§impl<'a> CompiledFlow<'a, usize>
impl<'a> CompiledFlow<'a, usize>
pub fn with_dynamic_id( self, id: impl QuotedWithContext<'a, usize, ()>, -) -> CompiledFlowWithId<'a>
Trait Implementations§
source§impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlow<'a, ()>
impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlow<'a, ()>
source§impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>
impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>
fn splice_untyped_ctx(self, ctx: &Ctx) -> Exprwhere
+) -> CompiledFlowWithId<'a>
Trait Implementations§
source§impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlow<'a, ()>
impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlow<'a, ()>
source§impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>
impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>
fn splice_untyped_ctx(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
fn splice_typed_ctx(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
fn splice_fn1_ctx<I, O>(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
diff --git a/doc/hydroflow_plus/builder/compiled/struct.CompiledFlowWithId.html b/doc/hydroflow_plus/builder/compiled/struct.CompiledFlowWithId.html
index c839929f1f7c..d64e4e980782 100644
--- a/doc/hydroflow_plus/builder/compiled/struct.CompiledFlowWithId.html
+++ b/doc/hydroflow_plus/builder/compiled/struct.CompiledFlowWithId.html
@@ -1,4 +1,4 @@
-CompiledFlowWithId in hydroflow_plus::builder::compiled - Rust Struct hydroflow_plus::builder::compiled::CompiledFlowWithId
source · pub struct CompiledFlowWithId<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlowWithId<'a>
source§impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>
source§fn splice_untyped_ctx(self, ctx: &Ctx) -> Exprwhere
+CompiledFlowWithId in hydroflow_plus::builder::compiled - Rust Struct hydroflow_plus::builder::compiled::CompiledFlowWithId
source · pub struct CompiledFlowWithId<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlowWithId<'a>
source§impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>
source§fn splice_untyped_ctx(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
source§fn splice_typed_ctx(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
source§fn splice_fn1_ctx<I, O>(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
index 75cdf0b35036..2e453ee8f1fd 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
@@ -1,4 +1,4 @@
cluster_members in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::cluster_members
source · pub fn cluster_members(
- cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
of_cluster: usize,
) -> impl QuotedWithContext<'_, &Vec<u32>, ()> + Copy
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
index d142be74764e..2f7f8434f84f 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
@@ -1,3 +1,3 @@
cluster_self_id in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::cluster_self_id
source · pub fn cluster_self_id(
- cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
) -> impl QuotedWithContext<'_, u32, ()> + Copy
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
index ba3b850f98aa..5b8ecfd1a9da 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
@@ -1,5 +1,5 @@
deploy_e2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_e2o
source · pub fn deploy_e2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
_e1_port: &str,
p2_port: &str,
) -> Expr
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
index 04bd6ebf1e9c..49666426215f 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
@@ -1,5 +1,5 @@
deploy_m2m in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_m2m
source · pub fn deploy_m2m(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
c1_port: &str,
c2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
index e00485c5ab58..8c9f8909aa9d 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
@@ -1,5 +1,5 @@
deploy_m2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_m2o
source · pub fn deploy_m2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
c1_port: &str,
p2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
index cfe1fe3be5b4..07654072fbab 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
@@ -1,5 +1,5 @@
deploy_o2e in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2e
source · pub fn deploy_o2e(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
_e2_port: &str,
) -> Expr
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
index 999e3587621a..b4f17ccc9449 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
@@ -1,5 +1,5 @@
deploy_o2m in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2m
source · pub fn deploy_o2m(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
c2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
index bda5e2688dc4..ad4462e80a4c 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
@@ -1,5 +1,5 @@
deploy_o2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2o
source · pub fn deploy_o2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
p2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html b/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
index 6b73f4b873a7..4165b6cc0e98 100644
--- a/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
+++ b/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
@@ -1,4 +1,4 @@
-DeployRuntime in hydroflow_plus::deploy::macro_runtime - Rust Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§fn has_trivial_node() -> bool
source§fn trivial_process(_id: usize) -> Self::Process
source§fn trivail_cluster(_id: usize) -> Self::Cluster
source§fn allocate_process_port(process: &Self::Process) -> Self::Port
source§fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
source§fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
source§fn o2o_sink_source(
+DeployRuntime in hydroflow_plus::deploy::macro_runtime - Rust Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§fn has_trivial_node() -> bool
source§fn trivial_process(_id: usize) -> Self::Process
source§fn trivail_cluster(_id: usize) -> Self::Cluster
source§fn allocate_process_port(process: &Self::Process) -> Self::Port
source§fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
source§fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
source§fn o2o_sink_source(
env: &Self::CompileEnv,
_p1: &Self::Process,
p1_port: &Self::Port,
diff --git a/doc/hydroflow_plus/deploy/trait.Deploy.html b/doc/hydroflow_plus/deploy/trait.Deploy.html
index 0216ecadb523..ff4cd90b0b97 100644
--- a/doc/hydroflow_plus/deploy/trait.Deploy.html
+++ b/doc/hydroflow_plus/deploy/trait.Deploy.html
@@ -175,4 +175,4 @@
of_cluster: usize,
) -> impl QuotedWithContext<'a, &'a Vec<u32>, ()> + Copy + 'a
sourcefn cluster_self_id(
env: &Self::CompileEnv,
-) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'a
Provided Methods§
sourcefn has_trivial_node() -> bool
sourcefn trivial_process(_id: usize) -> Self::Process
sourcefn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
This trait is not object safe.Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§type GraphId = usize
\ No newline at end of file
+) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'aProvided Methods§
sourcefn has_trivial_node() -> bool
sourcefn trivial_process(_id: usize) -> Self::Process
sourcefn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
This trait is not object safe.Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§type GraphId = usize
\ No newline at end of file
diff --git a/doc/hydroflow_plus/index.html b/doc/hydroflow_plus/index.html
index f0261b8aaa41..95bb6244267f 100644
--- a/doc/hydroflow_plus/index.html
+++ b/doc/hydroflow_plus/index.html
@@ -1 +1 @@
-hydroflow_plus - Rust Crate hydroflow_plus
source · Re-exports§
pub use runtime_context::RUNTIME_CONTEXT;
pub use boundedness::Bounded;
pub use boundedness::Unbounded;
pub use stream::NoOrder;
pub use stream::Stream;
pub use stream::TotalOrder;
pub use singleton::Singleton;
pub use optional::Optional;
pub use location::cluster::CLUSTER_SELF_ID;
pub use location::Cluster;
pub use location::ClusterId;
pub use location::ExternalProcess;
pub use location::Location;
pub use location::Process;
pub use location::Tick;
pub use location::Timestamped;
pub use builder::FlowBuilder;
pub use hydroflow;
Modules§
Macros§
- Creates a quoted expression for Hydroflow+.
\ No newline at end of file
+hydroflow_plus - Rust Crate hydroflow_plus
source · Re-exports§
pub use runtime_context::RUNTIME_CONTEXT;
pub use boundedness::Bounded;
pub use boundedness::Unbounded;
pub use stream::NoOrder;
pub use stream::Stream;
pub use stream::TotalOrder;
pub use singleton::Singleton;
pub use optional::Optional;
pub use location::cluster::CLUSTER_SELF_ID;
pub use location::Cluster;
pub use location::ClusterId;
pub use location::ExternalProcess;
pub use location::Location;
pub use location::Process;
pub use location::Tick;
pub use location::Timestamped;
pub use builder::FlowBuilder;
pub use hydroflow;
Modules§
Macros§
- Creates a quoted expression for Hydroflow+.
\ No newline at end of file
diff --git a/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html b/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
index a762e2d49271..bbdac7da4c6e 100644
--- a/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
+++ b/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
@@ -1,4 +1,4 @@
-RuntimeContext in hydroflow_plus::runtime_context - Rust Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
Returns a copy of the value. Read more1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
source§impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
§impl<'a> Freeze for RuntimeContext<'a>
§impl<'a> RefUnwindSafe for RuntimeContext<'a>
§impl<'a> Send for RuntimeContext<'a>
§impl<'a> Sync for RuntimeContext<'a>
§impl<'a> Unpin for RuntimeContext<'a>
§impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> Any for Twhere
+RuntimeContext in hydroflow_plus::runtime_context - Rust Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
Returns a copy of the value. Read more1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
source§impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
§impl<'a> Freeze for RuntimeContext<'a>
§impl<'a> RefUnwindSafe for RuntimeContext<'a>
§impl<'a> Send for RuntimeContext<'a>
§impl<'a> Sync for RuntimeContext<'a>
§impl<'a> Unpin for RuntimeContext<'a>
§impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moresource§impl<T> CloneToUninit for Twhere
diff --git a/doc/trait.impl/stageleft/trait.QuotedWithContext.js b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
index 556b89946ac6..14f213049592 100644
--- a/doc/trait.impl/stageleft/trait.QuotedWithContext.js
+++ b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
@@ -1,9 +1,9 @@
(function() {
- var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
+ var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
if (window.register_implementors) {
window.register_implementors(implementors);
} else {
window.pending_implementors = implementors;
}
})()
-//{"start":57,"fragment_lengths":[3742,17]}
\ No newline at end of file
+//{"start":57,"fragment_lengths":[3468,17]}
\ No newline at end of file
diff --git a/doc/type.impl/alloc/rc/struct.Rc.js b/doc/type.impl/alloc/rc/struct.Rc.js
index 5a5903c96393..c33fbc8e46e1 100644
--- a/doc/type.impl/alloc/rc/struct.Rc.js
+++ b/doc/type.impl/alloc/rc/struct.Rc.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["source§impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[168210,167119]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[167402,167119]}
\ No newline at end of file
diff --git a/doc/type.impl/std/collections/hash/map/struct.HashMap.js b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
index fad5a9ba6440..52e40dcf3533 100644
--- a/doc/type.impl/std/collections/hash/map/struct.HashMap.js
+++ b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[172279]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[171937]}
\ No newline at end of file
Struct hydroflow_plus::builder::compiled::CompiledFlowWithId
source · pub struct CompiledFlowWithId<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlowWithId<'a>
impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlowWithId<'a>
source§impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>
impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>
fn splice_untyped_ctx(self, ctx: &Ctx) -> Exprwhere
+CompiledFlowWithId in hydroflow_plus::builder::compiled - Rust Struct hydroflow_plus::builder::compiled::CompiledFlowWithId
source · pub struct CompiledFlowWithId<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlowWithId<'a>
source§impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>
source§fn splice_untyped_ctx(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
source§fn splice_typed_ctx(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
source§fn splice_fn1_ctx<I, O>(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
index 75cdf0b35036..2e453ee8f1fd 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
@@ -1,4 +1,4 @@
cluster_members in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::cluster_members
source · pub fn cluster_members(
- cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
of_cluster: usize,
) -> impl QuotedWithContext<'_, &Vec<u32>, ()> + Copy
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
index d142be74764e..2f7f8434f84f 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
@@ -1,3 +1,3 @@
cluster_self_id in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::cluster_self_id
source · pub fn cluster_self_id(
- cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
) -> impl QuotedWithContext<'_, u32, ()> + Copy
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
index ba3b850f98aa..5b8ecfd1a9da 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
@@ -1,5 +1,5 @@
deploy_e2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_e2o
source · pub fn deploy_e2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
_e1_port: &str,
p2_port: &str,
) -> Expr
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
index 04bd6ebf1e9c..49666426215f 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
@@ -1,5 +1,5 @@
deploy_m2m in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_m2m
source · pub fn deploy_m2m(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
c1_port: &str,
c2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
index e00485c5ab58..8c9f8909aa9d 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
@@ -1,5 +1,5 @@
deploy_m2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_m2o
source · pub fn deploy_m2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
c1_port: &str,
p2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
index cfe1fe3be5b4..07654072fbab 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
@@ -1,5 +1,5 @@
deploy_o2e in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2e
source · pub fn deploy_o2e(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
_e2_port: &str,
) -> Expr
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
index 999e3587621a..b4f17ccc9449 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
@@ -1,5 +1,5 @@
deploy_o2m in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2m
source · pub fn deploy_o2m(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
c2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
index bda5e2688dc4..ad4462e80a4c 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
@@ -1,5 +1,5 @@
deploy_o2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2o
source · pub fn deploy_o2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
p2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html b/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
index 6b73f4b873a7..4165b6cc0e98 100644
--- a/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
+++ b/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
@@ -1,4 +1,4 @@
-DeployRuntime in hydroflow_plus::deploy::macro_runtime - Rust Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§fn has_trivial_node() -> bool
source§fn trivial_process(_id: usize) -> Self::Process
source§fn trivail_cluster(_id: usize) -> Self::Cluster
source§fn allocate_process_port(process: &Self::Process) -> Self::Port
source§fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
source§fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
source§fn o2o_sink_source(
+DeployRuntime in hydroflow_plus::deploy::macro_runtime - Rust Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§fn has_trivial_node() -> bool
source§fn trivial_process(_id: usize) -> Self::Process
source§fn trivail_cluster(_id: usize) -> Self::Cluster
source§fn allocate_process_port(process: &Self::Process) -> Self::Port
source§fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
source§fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
source§fn o2o_sink_source(
env: &Self::CompileEnv,
_p1: &Self::Process,
p1_port: &Self::Port,
diff --git a/doc/hydroflow_plus/deploy/trait.Deploy.html b/doc/hydroflow_plus/deploy/trait.Deploy.html
index 0216ecadb523..ff4cd90b0b97 100644
--- a/doc/hydroflow_plus/deploy/trait.Deploy.html
+++ b/doc/hydroflow_plus/deploy/trait.Deploy.html
@@ -175,4 +175,4 @@
of_cluster: usize,
) -> impl QuotedWithContext<'a, &'a Vec<u32>, ()> + Copy + 'a
sourcefn cluster_self_id(
env: &Self::CompileEnv,
-) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'a
Provided Methods§
sourcefn has_trivial_node() -> bool
sourcefn trivial_process(_id: usize) -> Self::Process
sourcefn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
This trait is not object safe.Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§type GraphId = usize
\ No newline at end of file
+) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'aProvided Methods§
sourcefn has_trivial_node() -> bool
sourcefn trivial_process(_id: usize) -> Self::Process
sourcefn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
This trait is not object safe.Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§type GraphId = usize
\ No newline at end of file
diff --git a/doc/hydroflow_plus/index.html b/doc/hydroflow_plus/index.html
index f0261b8aaa41..95bb6244267f 100644
--- a/doc/hydroflow_plus/index.html
+++ b/doc/hydroflow_plus/index.html
@@ -1 +1 @@
-hydroflow_plus - Rust Crate hydroflow_plus
source · Re-exports§
pub use runtime_context::RUNTIME_CONTEXT;
pub use boundedness::Bounded;
pub use boundedness::Unbounded;
pub use stream::NoOrder;
pub use stream::Stream;
pub use stream::TotalOrder;
pub use singleton::Singleton;
pub use optional::Optional;
pub use location::cluster::CLUSTER_SELF_ID;
pub use location::Cluster;
pub use location::ClusterId;
pub use location::ExternalProcess;
pub use location::Location;
pub use location::Process;
pub use location::Tick;
pub use location::Timestamped;
pub use builder::FlowBuilder;
pub use hydroflow;
Modules§
Macros§
- Creates a quoted expression for Hydroflow+.
\ No newline at end of file
+hydroflow_plus - Rust Crate hydroflow_plus
source · Re-exports§
pub use runtime_context::RUNTIME_CONTEXT;
pub use boundedness::Bounded;
pub use boundedness::Unbounded;
pub use stream::NoOrder;
pub use stream::Stream;
pub use stream::TotalOrder;
pub use singleton::Singleton;
pub use optional::Optional;
pub use location::cluster::CLUSTER_SELF_ID;
pub use location::Cluster;
pub use location::ClusterId;
pub use location::ExternalProcess;
pub use location::Location;
pub use location::Process;
pub use location::Tick;
pub use location::Timestamped;
pub use builder::FlowBuilder;
pub use hydroflow;
Modules§
Macros§
- Creates a quoted expression for Hydroflow+.
\ No newline at end of file
diff --git a/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html b/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
index a762e2d49271..bbdac7da4c6e 100644
--- a/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
+++ b/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
@@ -1,4 +1,4 @@
-RuntimeContext in hydroflow_plus::runtime_context - Rust Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
Returns a copy of the value. Read more1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
source§impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
§impl<'a> Freeze for RuntimeContext<'a>
§impl<'a> RefUnwindSafe for RuntimeContext<'a>
§impl<'a> Send for RuntimeContext<'a>
§impl<'a> Sync for RuntimeContext<'a>
§impl<'a> Unpin for RuntimeContext<'a>
§impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> Any for Twhere
+RuntimeContext in hydroflow_plus::runtime_context - Rust Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
Returns a copy of the value. Read more1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
source§impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
§impl<'a> Freeze for RuntimeContext<'a>
§impl<'a> RefUnwindSafe for RuntimeContext<'a>
§impl<'a> Send for RuntimeContext<'a>
§impl<'a> Sync for RuntimeContext<'a>
§impl<'a> Unpin for RuntimeContext<'a>
§impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moresource§impl<T> CloneToUninit for Twhere
diff --git a/doc/trait.impl/stageleft/trait.QuotedWithContext.js b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
index 556b89946ac6..14f213049592 100644
--- a/doc/trait.impl/stageleft/trait.QuotedWithContext.js
+++ b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
@@ -1,9 +1,9 @@
(function() {
- var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
+ var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
if (window.register_implementors) {
window.register_implementors(implementors);
} else {
window.pending_implementors = implementors;
}
})()
-//{"start":57,"fragment_lengths":[3742,17]}
\ No newline at end of file
+//{"start":57,"fragment_lengths":[3468,17]}
\ No newline at end of file
diff --git a/doc/type.impl/alloc/rc/struct.Rc.js b/doc/type.impl/alloc/rc/struct.Rc.js
index 5a5903c96393..c33fbc8e46e1 100644
--- a/doc/type.impl/alloc/rc/struct.Rc.js
+++ b/doc/type.impl/alloc/rc/struct.Rc.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["source§impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[168210,167119]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[167402,167119]}
\ No newline at end of file
diff --git a/doc/type.impl/std/collections/hash/map/struct.HashMap.js b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
index fad5a9ba6440..52e40dcf3533 100644
--- a/doc/type.impl/std/collections/hash/map/struct.HashMap.js
+++ b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[172279]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[171937]}
\ No newline at end of file
Struct hydroflow_plus::builder::compiled::CompiledFlowWithId
source · pub struct CompiledFlowWithId<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlowWithId<'a>
impl<'a, Ctx> FreeVariableWithContext<Ctx> for CompiledFlowWithId<'a>
source§impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>
impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>
fn splice_untyped_ctx(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
fn splice_typed_ctx(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
fn splice_fn1_ctx<I, O>(self, ctx: &Ctx) -> Exprwhere
Self: Sized,
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
index 75cdf0b35036..2e453ee8f1fd 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_members.html
@@ -1,4 +1,4 @@
cluster_members in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::cluster_members
source · pub fn cluster_members(
- cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
of_cluster: usize,
) -> impl QuotedWithContext<'_, &Vec<u32>, ()> + Copy
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
index d142be74764e..2f7f8434f84f 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.cluster_self_id.html
@@ -1,3 +1,3 @@
cluster_self_id in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::cluster_self_id
source · pub fn cluster_self_id(
- cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
) -> impl QuotedWithContext<'_, u32, ()> + Copy
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
index ba3b850f98aa..5b8ecfd1a9da 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_e2o.html
@@ -1,5 +1,5 @@
deploy_e2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_e2o
source · pub fn deploy_e2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
_e1_port: &str,
p2_port: &str,
) -> Expr
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
index 04bd6ebf1e9c..49666426215f 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2m.html
@@ -1,5 +1,5 @@
deploy_m2m in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_m2m
source · pub fn deploy_m2m(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
c1_port: &str,
c2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
index e00485c5ab58..8c9f8909aa9d 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_m2o.html
@@ -1,5 +1,5 @@
deploy_m2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_m2o
source · pub fn deploy_m2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
c1_port: &str,
p2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
index cfe1fe3be5b4..07654072fbab 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2e.html
@@ -1,5 +1,5 @@
deploy_o2e in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2e
source · pub fn deploy_o2e(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
_e2_port: &str,
) -> Expr
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
index 999e3587621a..b4f17ccc9449 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2m.html
@@ -1,5 +1,5 @@
deploy_o2m in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2m
source · pub fn deploy_o2m(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
c2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
index bda5e2688dc4..ad4462e80a4c 100644
--- a/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
+++ b/doc/hydroflow_plus/deploy/deploy_runtime/fn.deploy_o2o.html
@@ -1,5 +1,5 @@
deploy_o2o in hydroflow_plus::deploy::deploy_runtime - Rust Function hydroflow_plus::deploy::deploy_runtime::deploy_o2o
source · pub fn deploy_o2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
p2_port: &str,
) -> (Expr, Expr)
\ No newline at end of file
diff --git a/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html b/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
index 6b73f4b873a7..4165b6cc0e98 100644
--- a/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
+++ b/doc/hydroflow_plus/deploy/macro_runtime/struct.DeployRuntime.html
@@ -1,4 +1,4 @@
-DeployRuntime in hydroflow_plus::deploy::macro_runtime - Rust Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§fn has_trivial_node() -> bool
source§fn trivial_process(_id: usize) -> Self::Process
source§fn trivail_cluster(_id: usize) -> Self::Cluster
source§fn allocate_process_port(process: &Self::Process) -> Self::Port
source§fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
source§fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
source§fn o2o_sink_source(
+DeployRuntime in hydroflow_plus::deploy::macro_runtime - Rust Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§fn has_trivial_node() -> bool
source§fn trivial_process(_id: usize) -> Self::Process
source§fn trivail_cluster(_id: usize) -> Self::Cluster
source§fn allocate_process_port(process: &Self::Process) -> Self::Port
source§fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
source§fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
source§fn o2o_sink_source(
env: &Self::CompileEnv,
_p1: &Self::Process,
p1_port: &Self::Port,
diff --git a/doc/hydroflow_plus/deploy/trait.Deploy.html b/doc/hydroflow_plus/deploy/trait.Deploy.html
index 0216ecadb523..ff4cd90b0b97 100644
--- a/doc/hydroflow_plus/deploy/trait.Deploy.html
+++ b/doc/hydroflow_plus/deploy/trait.Deploy.html
@@ -175,4 +175,4 @@
of_cluster: usize,
) -> impl QuotedWithContext<'a, &'a Vec<u32>, ()> + Copy + 'a
sourcefn cluster_self_id(
env: &Self::CompileEnv,
-) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'a
Provided Methods§
sourcefn has_trivial_node() -> bool
sourcefn trivial_process(_id: usize) -> Self::Process
sourcefn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
This trait is not object safe.Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§type GraphId = usize
\ No newline at end of file
+) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'aProvided Methods§
sourcefn has_trivial_node() -> bool
sourcefn trivial_process(_id: usize) -> Self::Process
sourcefn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
This trait is not object safe.Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§type GraphId = usize
\ No newline at end of file
diff --git a/doc/hydroflow_plus/index.html b/doc/hydroflow_plus/index.html
index f0261b8aaa41..95bb6244267f 100644
--- a/doc/hydroflow_plus/index.html
+++ b/doc/hydroflow_plus/index.html
@@ -1 +1 @@
-hydroflow_plus - Rust Crate hydroflow_plus
source · Re-exports§
pub use runtime_context::RUNTIME_CONTEXT;
pub use boundedness::Bounded;
pub use boundedness::Unbounded;
pub use stream::NoOrder;
pub use stream::Stream;
pub use stream::TotalOrder;
pub use singleton::Singleton;
pub use optional::Optional;
pub use location::cluster::CLUSTER_SELF_ID;
pub use location::Cluster;
pub use location::ClusterId;
pub use location::ExternalProcess;
pub use location::Location;
pub use location::Process;
pub use location::Tick;
pub use location::Timestamped;
pub use builder::FlowBuilder;
pub use hydroflow;
Modules§
Macros§
- Creates a quoted expression for Hydroflow+.
\ No newline at end of file
+hydroflow_plus - Rust Crate hydroflow_plus
source · Re-exports§
pub use runtime_context::RUNTIME_CONTEXT;
pub use boundedness::Bounded;
pub use boundedness::Unbounded;
pub use stream::NoOrder;
pub use stream::Stream;
pub use stream::TotalOrder;
pub use singleton::Singleton;
pub use optional::Optional;
pub use location::cluster::CLUSTER_SELF_ID;
pub use location::Cluster;
pub use location::ClusterId;
pub use location::ExternalProcess;
pub use location::Location;
pub use location::Process;
pub use location::Tick;
pub use location::Timestamped;
pub use builder::FlowBuilder;
pub use hydroflow;
Modules§
Macros§
- Creates a quoted expression for Hydroflow+.
\ No newline at end of file
diff --git a/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html b/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
index a762e2d49271..bbdac7da4c6e 100644
--- a/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
+++ b/doc/hydroflow_plus/runtime_context/struct.RuntimeContext.html
@@ -1,4 +1,4 @@
-RuntimeContext in hydroflow_plus::runtime_context - Rust Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
Returns a copy of the value. Read more1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
source§impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
§impl<'a> Freeze for RuntimeContext<'a>
§impl<'a> RefUnwindSafe for RuntimeContext<'a>
§impl<'a> Send for RuntimeContext<'a>
§impl<'a> Sync for RuntimeContext<'a>
§impl<'a> Unpin for RuntimeContext<'a>
§impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> Any for Twhere
+RuntimeContext in hydroflow_plus::runtime_context - Rust Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
Returns a copy of the value. Read more1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
source§impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
§impl<'a> Freeze for RuntimeContext<'a>
§impl<'a> RefUnwindSafe for RuntimeContext<'a>
§impl<'a> Send for RuntimeContext<'a>
§impl<'a> Sync for RuntimeContext<'a>
§impl<'a> Unpin for RuntimeContext<'a>
§impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moresource§impl<T> CloneToUninit for Twhere
diff --git a/doc/trait.impl/stageleft/trait.QuotedWithContext.js b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
index 556b89946ac6..14f213049592 100644
--- a/doc/trait.impl/stageleft/trait.QuotedWithContext.js
+++ b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
@@ -1,9 +1,9 @@
(function() {
- var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
+ var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
if (window.register_implementors) {
window.register_implementors(implementors);
} else {
window.pending_implementors = implementors;
}
})()
-//{"start":57,"fragment_lengths":[3742,17]}
\ No newline at end of file
+//{"start":57,"fragment_lengths":[3468,17]}
\ No newline at end of file
diff --git a/doc/type.impl/alloc/rc/struct.Rc.js b/doc/type.impl/alloc/rc/struct.Rc.js
index 5a5903c96393..c33fbc8e46e1 100644
--- a/doc/type.impl/alloc/rc/struct.Rc.js
+++ b/doc/type.impl/alloc/rc/struct.Rc.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["source§impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[168210,167119]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[167402,167119]}
\ No newline at end of file
diff --git a/doc/type.impl/std/collections/hash/map/struct.HashMap.js b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
index fad5a9ba6440..52e40dcf3533 100644
--- a/doc/type.impl/std/collections/hash/map/struct.HashMap.js
+++ b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[172279]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[171937]}
\ No newline at end of file
Function hydroflow_plus::deploy::deploy_runtime::cluster_members
source · pub fn cluster_members(
- cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
of_cluster: usize,
) -> impl QuotedWithContext<'_, &Vec<u32>, ()> + Copy
Function hydroflow_plus::deploy::deploy_runtime::cluster_self_id
source · pub fn cluster_self_id(
- cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ cli: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
) -> impl QuotedWithContext<'_, u32, ()> + Copy
Function hydroflow_plus::deploy::deploy_runtime::deploy_e2o
source · pub fn deploy_e2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
_e1_port: &str,
p2_port: &str,
) -> Expr
Function hydroflow_plus::deploy::deploy_runtime::deploy_m2m
source · pub fn deploy_m2m(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
c1_port: &str,
c2_port: &str,
) -> (Expr, Expr)
Function hydroflow_plus::deploy::deploy_runtime::deploy_m2o
source · pub fn deploy_m2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
c1_port: &str,
p2_port: &str,
) -> (Expr, Expr)
Function hydroflow_plus::deploy::deploy_runtime::deploy_o2e
source · pub fn deploy_o2e(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
_e2_port: &str,
) -> Expr
Function hydroflow_plus::deploy::deploy_runtime::deploy_o2m
source · pub fn deploy_o2m(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
c2_port: &str,
) -> (Expr, Expr)
Function hydroflow_plus::deploy::deploy_runtime::deploy_o2o
source · pub fn deploy_o2o(
- env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
+ env: RuntimeData<&DeployPorts<HydroflowPlusMeta>>,
p1_port: &str,
p2_port: &str,
) -> (Expr, Expr)
Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
impl<'a> Deploy<'a> for DeployRuntime
type InstantiateEnv = ()
type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
type Process = DeployRuntimeNode
type Cluster = DeployRuntimeCluster
type ExternalProcess = DeployRuntimeNode
type Port = String
type ExternalRawPort = ()
type Meta = ()
fn has_trivial_node() -> bool
fn trivial_process(_id: usize) -> Self::Process
fn trivail_cluster(_id: usize) -> Self::Cluster
fn allocate_process_port(process: &Self::Process) -> Self::Port
fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
fn o2o_sink_source(
+DeployRuntime in hydroflow_plus::deploy::macro_runtime - Rust Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§fn has_trivial_node() -> bool
source§fn trivial_process(_id: usize) -> Self::Process
source§fn trivail_cluster(_id: usize) -> Self::Cluster
source§fn allocate_process_port(process: &Self::Process) -> Self::Port
source§fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
source§fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
source§fn o2o_sink_source(
env: &Self::CompileEnv,
_p1: &Self::Process,
p1_port: &Self::Port,
diff --git a/doc/hydroflow_plus/deploy/trait.Deploy.html b/doc/hydroflow_plus/deploy/trait.Deploy.html
index 0216ecadb523..ff4cd90b0b97 100644
--- a/doc/hydroflow_plus/deploy/trait.Deploy.html
+++ b/doc/hydroflow_plus/deploy/trait.Deploy.html
@@ -175,4 +175,4 @@
of_cluster: usize,
) -> impl QuotedWithContext<'a, &'a Vec<u32>, ()> + Copy + 'a
sourcefn cluster_self_id(
env: &Self::CompileEnv,
-) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'a
Provided Methods§
sourcefn has_trivial_node() -> bool
sourcefn trivial_process(_id: usize) -> Self::Process
sourcefn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
This trait is not object safe.Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§type GraphId = usize
\ No newline at end of file
+) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'aProvided Methods§
sourcefn has_trivial_node() -> bool
sourcefn trivial_process(_id: usize) -> Self::Process
sourcefn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
This trait is not object safe.Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
source§type InstantiateEnv = ()
source§type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
source§type Process = DeployRuntimeNode
source§type Cluster = DeployRuntimeCluster
source§type ExternalProcess = DeployRuntimeNode
source§type Port = String
source§type ExternalRawPort = ()
source§type Meta = ()
source§type GraphId = usize
Struct hydroflow_plus::deploy::macro_runtime::DeployRuntime
source · pub struct DeployRuntime {}
Trait Implementations§
source§impl ClusterSpec<'_, DeployRuntime> for ()
impl ClusterSpec<'_, DeployRuntime> for ()
source§impl<'a> Deploy<'a> for DeployRuntime
impl<'a> Deploy<'a> for DeployRuntime
type InstantiateEnv = ()
type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
type Process = DeployRuntimeNode
type Cluster = DeployRuntimeCluster
type ExternalProcess = DeployRuntimeNode
type Port = String
type ExternalRawPort = ()
type Meta = ()
fn has_trivial_node() -> bool
fn trivial_process(_id: usize) -> Self::Process
fn trivail_cluster(_id: usize) -> Self::Cluster
fn allocate_process_port(process: &Self::Process) -> Self::Port
fn allocate_cluster_port(cluster: &Self::Cluster) -> Self::Port
fn allocate_external_port(_external: &Self::ExternalProcess) -> Self::Port
fn o2o_sink_source( env: &Self::CompileEnv, _p1: &Self::Process, p1_port: &Self::Port, diff --git a/doc/hydroflow_plus/deploy/trait.Deploy.html b/doc/hydroflow_plus/deploy/trait.Deploy.html index 0216ecadb523..ff4cd90b0b97 100644 --- a/doc/hydroflow_plus/deploy/trait.Deploy.html +++ b/doc/hydroflow_plus/deploy/trait.Deploy.html @@ -175,4 +175,4 @@ of_cluster: usize, ) -> impl QuotedWithContext<'a, &'a Vec<u32>, ()> + Copy + 'a
fn cluster_self_id( env: &Self::CompileEnv, -) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'a
Provided Methods§
fn has_trivial_node() -> bool
fn trivial_process(_id: usize) -> Self::Process
fn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
impl<'a> Deploy<'a> for DeployRuntime
type InstantiateEnv = ()
type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
type Process = DeployRuntimeNode
type Cluster = DeployRuntimeCluster
type ExternalProcess = DeployRuntimeNode
type Port = String
type ExternalRawPort = ()
type Meta = ()
type GraphId = usize
Provided Methods§
fn has_trivial_node() -> bool
fn trivial_process(_id: usize) -> Self::Process
fn trivail_cluster(_id: usize) -> Self::Cluster
Object Safety§
Implementors§
source§impl<'a> Deploy<'a> for DeployRuntime
impl<'a> Deploy<'a> for DeployRuntime
type InstantiateEnv = ()
type CompileEnv = RuntimeData<&'a DeployPorts<HydroflowPlusMeta>>
type Process = DeployRuntimeNode
type Cluster = DeployRuntimeCluster
type ExternalProcess = DeployRuntimeNode
type Port = String
type ExternalRawPort = ()
type Meta = ()
type GraphId = usize
Crate hydroflow_plus
source ·Re-exports§
pub use runtime_context::RUNTIME_CONTEXT;
pub use boundedness::Bounded;
pub use boundedness::Unbounded;
pub use stream::NoOrder;
pub use stream::Stream;
pub use stream::TotalOrder;
pub use singleton::Singleton;
pub use optional::Optional;
pub use location::cluster::CLUSTER_SELF_ID;
pub use location::Cluster;
pub use location::ClusterId;
pub use location::ExternalProcess;
pub use location::Location;
pub use location::Process;
pub use location::Tick;
pub use location::Timestamped;
pub use builder::FlowBuilder;
pub use hydroflow;
Modules§
Macros§
- Creates a quoted expression for Hydroflow+.
Crate hydroflow_plus
source ·Re-exports§
pub use runtime_context::RUNTIME_CONTEXT;
pub use boundedness::Bounded;
pub use boundedness::Unbounded;
pub use stream::NoOrder;
pub use stream::Stream;
pub use stream::TotalOrder;
pub use singleton::Singleton;
pub use optional::Optional;
pub use location::cluster::CLUSTER_SELF_ID;
pub use location::Cluster;
pub use location::ClusterId;
pub use location::ExternalProcess;
pub use location::Location;
pub use location::Process;
pub use location::Tick;
pub use location::Timestamped;
pub use builder::FlowBuilder;
pub use hydroflow;
Modules§
Macros§
- Creates a quoted expression for Hydroflow+.
Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
fn clone(&self) -> RuntimeContext<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
impl<'a> Freeze for RuntimeContext<'a>
impl<'a> RefUnwindSafe for RuntimeContext<'a>
impl<'a> Send for RuntimeContext<'a>
impl<'a> Sync for RuntimeContext<'a>
impl<'a> Unpin for RuntimeContext<'a>
impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> Any for Twhere
+RuntimeContext in hydroflow_plus::runtime_context - Rust Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
Returns a copy of the value. Read more1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
source§impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
§impl<'a> Freeze for RuntimeContext<'a>
§impl<'a> RefUnwindSafe for RuntimeContext<'a>
§impl<'a> Send for RuntimeContext<'a>
§impl<'a> Sync for RuntimeContext<'a>
§impl<'a> Unpin for RuntimeContext<'a>
§impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moresource§impl<T> CloneToUninit for Twhere
diff --git a/doc/trait.impl/stageleft/trait.QuotedWithContext.js b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
index 556b89946ac6..14f213049592 100644
--- a/doc/trait.impl/stageleft/trait.QuotedWithContext.js
+++ b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
@@ -1,9 +1,9 @@
(function() {
- var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
+ var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
if (window.register_implementors) {
window.register_implementors(implementors);
} else {
window.pending_implementors = implementors;
}
})()
-//{"start":57,"fragment_lengths":[3742,17]}
\ No newline at end of file
+//{"start":57,"fragment_lengths":[3468,17]}
\ No newline at end of file
diff --git a/doc/type.impl/alloc/rc/struct.Rc.js b/doc/type.impl/alloc/rc/struct.Rc.js
index 5a5903c96393..c33fbc8e46e1 100644
--- a/doc/type.impl/alloc/rc/struct.Rc.js
+++ b/doc/type.impl/alloc/rc/struct.Rc.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["source§impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[168210,167119]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[167402,167119]}
\ No newline at end of file
diff --git a/doc/type.impl/std/collections/hash/map/struct.HashMap.js b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
index fad5a9ba6440..52e40dcf3533 100644
--- a/doc/type.impl/std/collections/hash/map/struct.HashMap.js
+++ b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[172279]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[171937]}
\ No newline at end of file
impl<T> Any for Twhere
+RuntimeContext in hydroflow_plus::runtime_context - Rust Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
Returns a copy of the value. Read more1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
source§impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
§impl<'a> Freeze for RuntimeContext<'a>
§impl<'a> RefUnwindSafe for RuntimeContext<'a>
§impl<'a> Send for RuntimeContext<'a>
§impl<'a> Sync for RuntimeContext<'a>
§impl<'a> Unpin for RuntimeContext<'a>
§impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moresource§impl<T> CloneToUninit for Twhere
diff --git a/doc/trait.impl/stageleft/trait.QuotedWithContext.js b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
index 556b89946ac6..14f213049592 100644
--- a/doc/trait.impl/stageleft/trait.QuotedWithContext.js
+++ b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
@@ -1,9 +1,9 @@
(function() {
- var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
+ var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
if (window.register_implementors) {
window.register_implementors(implementors);
} else {
window.pending_implementors = implementors;
}
})()
-//{"start":57,"fragment_lengths":[3742,17]}
\ No newline at end of file
+//{"start":57,"fragment_lengths":[3468,17]}
\ No newline at end of file
diff --git a/doc/type.impl/alloc/rc/struct.Rc.js b/doc/type.impl/alloc/rc/struct.Rc.js
index 5a5903c96393..c33fbc8e46e1 100644
--- a/doc/type.impl/alloc/rc/struct.Rc.js
+++ b/doc/type.impl/alloc/rc/struct.Rc.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["source§impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[168210,167119]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[167402,167119]}
\ No newline at end of file
diff --git a/doc/type.impl/std/collections/hash/map/struct.HashMap.js b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
index fad5a9ba6440..52e40dcf3533 100644
--- a/doc/type.impl/std/collections/hash/map/struct.HashMap.js
+++ b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[172279]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[171937]}
\ No newline at end of file
Struct hydroflow_plus::runtime_context::RuntimeContext
source · pub struct RuntimeContext<'a> { /* private fields */ }
Trait Implementations§
source§impl<'a> Clone for RuntimeContext<'a>
impl<'a> Clone for RuntimeContext<'a>
source§fn clone(&self) -> RuntimeContext<'a>
fn clone(&self) -> RuntimeContext<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
impl<'a, L: Location<'a>> FreeVariableWithContext<L> for RuntimeContext<'a>
impl<'a> Copy for RuntimeContext<'a>
Auto Trait Implementations§
impl<'a> Freeze for RuntimeContext<'a>
impl<'a> RefUnwindSafe for RuntimeContext<'a>
impl<'a> Send for RuntimeContext<'a>
impl<'a> Sync for RuntimeContext<'a>
impl<'a> Unpin for RuntimeContext<'a>
impl<'a> UnwindSafe for RuntimeContext<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
diff --git a/doc/trait.impl/stageleft/trait.QuotedWithContext.js b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
index 556b89946ac6..14f213049592 100644
--- a/doc/trait.impl/stageleft/trait.QuotedWithContext.js
+++ b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
@@ -1,9 +1,9 @@
(function() {
- var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
+ var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
if (window.register_implementors) {
window.register_implementors(implementors);
} else {
window.pending_implementors = implementors;
}
})()
-//{"start":57,"fragment_lengths":[3742,17]}
\ No newline at end of file
+//{"start":57,"fragment_lengths":[3468,17]}
\ No newline at end of file
diff --git a/doc/type.impl/alloc/rc/struct.Rc.js b/doc/type.impl/alloc/rc/struct.Rc.js
index 5a5903c96393..c33fbc8e46e1 100644
--- a/doc/type.impl/alloc/rc/struct.Rc.js
+++ b/doc/type.impl/alloc/rc/struct.Rc.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["source§impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[168210,167119]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[167402,167119]}
\ No newline at end of file
diff --git a/doc/type.impl/std/collections/hash/map/struct.HashMap.js b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
index fad5a9ba6440..52e40dcf3533 100644
--- a/doc/type.impl/std/collections/hash/map/struct.HashMap.js
+++ b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[172279]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[171937]}
\ No newline at end of file
impl<T> CloneToUninit for Twhere
diff --git a/doc/trait.impl/stageleft/trait.QuotedWithContext.js b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
index 556b89946ac6..14f213049592 100644
--- a/doc/trait.impl/stageleft/trait.QuotedWithContext.js
+++ b/doc/trait.impl/stageleft/trait.QuotedWithContext.js
@@ -1,9 +1,9 @@
(function() {
- var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
+ var implementors = Object.fromEntries([["hydroflow_plus",[["impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec<ClusterId<C>>, Ctx> for ClusterIds<'a, C>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()>"],["impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a>"],["impl<'a, L: Location<'a>> QuotedWithContext<'a, ClusterId<<<L as Location<'a>>::Root as IsCluster>::Tag>, L> for ClusterSelfId<'a>"]]],["stageleft",[]]]);
if (window.register_implementors) {
window.register_implementors(implementors);
} else {
window.pending_implementors = implementors;
}
})()
-//{"start":57,"fragment_lengths":[3742,17]}
\ No newline at end of file
+//{"start":57,"fragment_lengths":[3468,17]}
\ No newline at end of file
diff --git a/doc/type.impl/alloc/rc/struct.Rc.js b/doc/type.impl/alloc/rc/struct.Rc.js
index 5a5903c96393..c33fbc8e46e1 100644
--- a/doc/type.impl/alloc/rc/struct.Rc.js
+++ b/doc/type.impl/alloc/rc/struct.Rc.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["source§impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","hydroflow_plus::builder::FlowState"],["","AsRawFd","hydroflow_plus::builder::FlowState"],["","AsRef","hydroflow_plus::builder::FlowState"],["","Borrow","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","hydroflow_plus::builder::FlowState"],["","Debug","hydroflow_plus::builder::FlowState"],["","Default","hydroflow_plus::builder::FlowState"],["","Deref","hydroflow_plus::builder::FlowState"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::builder::FlowState"],["","Display","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From>","hydroflow_plus::builder::FlowState"],["","From","hydroflow_plus::builder::FlowState"],["","HandoffMeta","hydroflow_plus::builder::FlowState"],["","Hash","hydroflow_plus::builder::FlowState"],["","LocalSpawn","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","hydroflow_plus::builder::FlowState"],["","Pointer","hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"hydroflow_plus::builder::FlowState"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::builder::FlowState"],["","Spawn","hydroflow_plus::builder::FlowState"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","hydroflow_plus::builder::FlowState"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","hydroflow_plus::builder::FlowState"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","hydroflow_plus::builder::FlowState"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","hydroflow_plus::builder::FlowState"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","hydroflow_plus::builder::FlowState"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","hydroflow_plus::builder::FlowState"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","hydroflow_plus::builder::FlowState"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","hydroflow_plus::builder::FlowState"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","hydroflow_plus::builder::FlowState"]]],["topolotree",[["1.69.0 · source§impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more","AsFd","topolotree::ContributionAgg"],["","AsRawFd","topolotree::ContributionAgg"],["","AsRef","topolotree::ContributionAgg"],["","Borrow","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
\nThis creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
\n1.0.0 · source§fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more","Clone","topolotree::ContributionAgg"],["","Debug","topolotree::ContributionAgg"],["","Default","topolotree::ContributionAgg"],["","Deref","topolotree::ContributionAgg"],["source§impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nDeserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
\nsource§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","topolotree::ContributionAgg"],["","Display","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
Drops the Rc
.
\nThis will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
\n§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
\n","Drop","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From>","topolotree::ContributionAgg"],["","From","topolotree::ContributionAgg"],["","HandoffMeta","topolotree::ContributionAgg"],["","Hash","topolotree::ContributionAgg"],["","LocalSpawn","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
\nThe two are compared by calling cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
\n1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
Compares and returns the maximum of two values. Read more","Ord","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
\nTwo Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
\nsource§fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
\nTwo Rc
s are not equal if their inner values are not equal.
\nIf T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
\n","PartialEq","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
\nThe two are compared by calling partial_cmp()
on their inner values.
\n§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
\nsource§fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
\nThe two are compared by calling <
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
\nsource§fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
\nThe two are compared by calling <=
on their inner values.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
\n","PartialOrd","topolotree::ContributionAgg"],["","Pointer","topolotree::ContributionAgg"],["source§impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
\nThe raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
\n1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
\nGenerally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
\nnew_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
\nSince the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
\n§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
\n§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
\n1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
\nsourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
\n1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
Consumes the Rc
, returning the wrapped pointer and allocator.
\nTo avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
\n1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
\nsourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
\nThe raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
\n\n- If
U
is sized, it must have the same size and alignment as T
. This\nis trivially true if U
is T
. \n- If
U
is unsized, its data pointer must have the same size and\nalignment as T
. This is trivially true if Rc<U>
was constructed\nthrough Rc<T>
and then converted to Rc<U>
through an unsized\ncoercion. \n
\nNote that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
\nThe raw pointer must point to a block of memory allocated by alloc
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
\nThis function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
\nConvert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
\n1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
\nsourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
\nsourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
\n§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
\n1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
\nReturns None
otherwise, because it is not safe to\nmutate a shared value.
\nSee also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
\nsourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
Returns a mutable reference into the given Rc
,\nwithout any check.
\nSee also get_mut
, which is safe and does appropriate checks.
\n§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
\n§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
\nOther Rc
pointers to the same allocation must be to the same type.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
\nOther Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
\n\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
\n1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
\nIf there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
\nHowever, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
\nSee also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
\n§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
\nWeak
pointers will be disassociated:
\n\nuse std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
\nAssuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
\n§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
\n",0,"topolotree::ContributionAgg"],["source§impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
in the provided allocator.
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
\nsourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents in the provided allocator.
\n§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
\nsourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
\nsourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
\n§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
\nsourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
\n§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
\nsourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
\nSee MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
\n§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
\nsourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
\n1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, an Err
is returned with the same Rc
that was\npassed in.
\nThis will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
\n1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
\nOtherwise, None
is returned and the Rc
is dropped.
\nThis will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
\nRc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
\n",0,"topolotree::ContributionAgg"],["source§impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
\nSerializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
\nsource§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","topolotree::ContributionAgg"],["","Spawn","topolotree::ContributionAgg"],["source§impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
","ToTokens","topolotree::ContributionAgg"],["source§impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
","CoerceUnsized>","topolotree::ContributionAgg"],["source§impl<T, A> DerefPure for Rc<T, A>
","DerefPure","topolotree::ContributionAgg"],["source§impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
","DispatchFromDyn>","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> Eq for Rc<T, A>
","Eq","topolotree::ContributionAgg"],["source§impl<T, A> PinCoerceUnsized for Rc<T, A>
","PinCoerceUnsized","topolotree::ContributionAgg"],["1.58.0 · source§impl<T, A> RefUnwindSafe for Rc<T, A>
","RefUnwindSafe","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Send for Rc<T, A>
","Send","topolotree::ContributionAgg"],["1.0.0 · source§impl<T, A> !Sync for Rc<T, A>
","Sync","topolotree::ContributionAgg"],["1.33.0 · source§impl<T, A> Unpin for Rc<T, A>
","Unpin","topolotree::ContributionAgg"],["1.9.0 · source§impl<T, A> UnwindSafe for Rc<T, A>
","UnwindSafe","topolotree::ContributionAgg"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[168210,167119]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[167402,167119]}
\ No newline at end of file
diff --git a/doc/type.impl/std/collections/hash/map/struct.HashMap.js b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
index fad5a9ba6440..52e40dcf3533 100644
--- a/doc/type.impl/std/collections/hash/map/struct.HashMap.js
+++ b/doc/type.impl/std/collections/hash/map/struct.HashMap.js
@@ -1,9 +1,9 @@
(function() {
- var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
+ var type_impls = Object.fromEntries([["hydroflow_plus",[["","Accumulate<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clear","hydroflow_plus::ir::SeenTees"],["","Clone","hydroflow_plus::ir::SeenTees"],["","Collection","hydroflow_plus::ir::SeenTees"],["§impl<K, V> CollectionMut for HashMap<K, V>
","CollectionMut","hydroflow_plus::ir::SeenTees"],["","CollectionRef","hydroflow_plus::ir::SeenTees"],["","Debug","hydroflow_plus::ir::SeenTees"],["","Default","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more","Deserialize<'de>","hydroflow_plus::ir::SeenTees"],["1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (&'a K, &'a V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(&'a K, &'a V)>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read moresource§fn extend_one(&mut self, _: (K, V))
🔬This is a nightly-only experimental API. (extend_one
)Extends a collection with exactly one element.source§fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more","Extend<(K, V)>","hydroflow_plus::ir::SeenTees"],["","From<[(K, V); N]>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
","FromIterator<(K, V)>","hydroflow_plus::ir::SeenTees"],["","Get<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetKeyValue<&'a Q>","hydroflow_plus::ir::SeenTees"],["","GetMut<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
\nThe hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
\n1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n\n- Hash memoization
\n- Deferring the creation of an owned key until it is known to be required
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nBecause raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
\nIn particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n\n- Hash memoization
\n- Using a search key that doesn’t work with the Borrow trait
\n- Using custom comparison logic without newtype wrappers
\n
\nUnless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
\nImmutable raw entries have very limited use; you might instead want raw_entry_mut
.
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
\nThe created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
\n1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
\nThe hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
\nWarning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
\nThe hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
\n1.0.0 · sourcepub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
\n§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
\n1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
\n§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
\n§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
\n§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
\n1.0.0 · sourcepub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
\n1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
\nsourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
\nIf the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
\n§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
\n1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
\n§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
\n1.9.0 · sourcepub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
\n§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
\n",0,"hydroflow_plus::ir::SeenTees"],["source§impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
\n§Panics
\nPanics if the new allocation size overflows usize
.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
\n1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
\n§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
\n1.0.0 · sourcepub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
\n1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
\n1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
\n1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
\n1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
\nsourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once.
\nReturns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
\nsourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
\nReturns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
\nFor a safe alternative see get_many_mut
.
\n§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
\n1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
\n1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
\n1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
\nIf the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
\nsourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
\n1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
\n1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
\n",0,"hydroflow_plus::ir::SeenTees"],["§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
","HashMapExt","hydroflow_plus::ir::SeenTees"],["","Index<&Q>","hydroflow_plus::ir::SeenTees"],["source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.","IntoDeserializer<'de, E>","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
\n","IntoIterator","hydroflow_plus::ir::SeenTees"],["","Iter","hydroflow_plus::ir::SeenTees"],["","Keyed","hydroflow_plus::ir::SeenTees"],["","KeyedRef","hydroflow_plus::ir::SeenTees"],["","Len","hydroflow_plus::ir::SeenTees"],["","MapInsert","hydroflow_plus::ir::SeenTees"],["","MapIter","hydroflow_plus::ir::SeenTees"],["","MapIterMut","hydroflow_plus::ir::SeenTees"],["§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
Output type, should be Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
Map the values into using the map_fn
.","MapMapValues","hydroflow_plus::ir::SeenTees"],["","PartialEq","hydroflow_plus::ir::SeenTees"],["","Remove<&'a Q>","hydroflow_plus::ir::SeenTees"],["source§impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
Serialize this value into the given Serde serializer. Read more","Serialize","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionMut","hydroflow_plus::ir::SeenTees"],["","SimpleCollectionRef","hydroflow_plus::ir::SeenTees"],["","SimpleKeyedRef","hydroflow_plus::ir::SeenTees"],["1.0.0 · source§impl<K, V, S> Eq for HashMap<K, V, S>
","Eq","hydroflow_plus::ir::SeenTees"],["1.36.0 · source§impl<K, V, S> UnwindSafe for HashMap<K, V, S>
","UnwindSafe","hydroflow_plus::ir::SeenTees"]]]]);
if (window.register_type_impls) {
window.register_type_impls(type_impls);
} else {
window.pending_type_impls = type_impls;
}
})()
-//{"start":55,"fragment_lengths":[172279]}
\ No newline at end of file
+//{"start":55,"fragment_lengths":[171937]}
\ No newline at end of file
1.69.0 · source§impl<T> AsFd for Rc<T>
impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
1.0.0 · source§impl<T, A> Clone for Rc<T, A>
impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
This creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'de, T> Deserialize<'de> for Rc<T>
impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
Deserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
1.0.0 · source§impl<T, A> Drop for Rc<T, A>
impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
fn drop(&mut self)
Drops the Rc
.
This will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
source§impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
impl<H> HandoffMeta for Rc<RefCell<H>>where\n H: HandoffMeta,
1.0.0 · source§impl<T, A> Ord for Rc<T, A>
impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
The two are compared by calling cmp()
on their inner values.
§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
fn max(self, other: Self) -> Selfwhere\n Self: Sized,
1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
Two Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
If T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
source§fn ne(&self, other: &Rc<T, A>) -> bool
fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
Two Rc
s are not equal if their inner values are not equal.
If T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
The two are compared by calling partial_cmp()
on their inner values.
§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
source§fn lt(&self, other: &Rc<T, A>) -> bool
fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
The two are compared by calling <
on their inner values.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
source§fn le(&self, other: &Rc<T, A>) -> bool
fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
The two are compared by calling <=
on their inner values.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
source§impl<T> Rc<T>where\n T: ?Sized,
impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
pub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
The raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
- \n
- If
U
is sized, it must have the same size and alignment asT
. This\nis trivially true ifU
isT
. \n - If
U
is unsized, its data pointer must have the same size and\nalignment asT
. This is trivially true ifRc<U>
was constructed\nthroughRc<T>
and then converted toRc<U>
through an unsized\ncoercion. \n
Note that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
The raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
This function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Convert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
pub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
pub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
source§impl<T> Rc<T>
impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
pub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
Generally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
new_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
Since the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
pub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
sourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
pub fn new_zeroed() -> Rc<MaybeUninit<T>>
new_zeroed_alloc
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
sourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new(value: T) -> Result<Rc<T>, AllocError>
allocator_api
)Constructs a new Rc<T>
, returning an error if the allocation fails
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
sourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
sourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn allocator(this: &Rc<T, A>) -> &A
allocator_api
)Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
pub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
To avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
sourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
allocator_api
)Consumes the Rc
, returning the wrapped pointer and allocator.
To avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
pub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
sourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
allocator_api
)Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
The raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
- \n
- If
U
is sized, it must have the same size and alignment asT
. This\nis trivially true ifU
isT
. \n - If
U
is unsized, its data pointer must have the same size and\nalignment asT
. This is trivially true ifRc<U>
was constructed\nthroughRc<T>
and then converted toRc<U>
through an unsized\ncoercion. \n
Note that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
The raw pointer must point to a block of memory allocated by alloc
The user of from_raw
has to make sure a specific value of T
is only\ndropped once.
This function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Convert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
pub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
pub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
sourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
allocator_api
)Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
sourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
allocator_api
)Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
pub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
Returns None
otherwise, because it is not safe to\nmutate a shared value.
See also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
sourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
pub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
get_mut_unchecked
)Returns a mutable reference into the given Rc
,\nwithout any check.
See also get_mut
, which is safe and does appropriate checks.
§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
Other Rc
pointers to the same allocation must be to the same type.
#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
Other Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
pub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
pub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
If there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
However, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
See also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
Weak
pointers will be disassociated:
use std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
pub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
Assuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
source§impl<T, A> Rc<T, A>where\n A: Allocator,
impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_in(value: T, alloc: A) -> Rc<T, A>
allocator_api
)Constructs a new Rc
in the provided allocator.
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
sourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
allocator_api
)Constructs a new Rc
with uninitialized contents in the provided allocator.
§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
sourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
sourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
allocator_api
)Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
sourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
sourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
sourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
allocator_api
)Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
pub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
Otherwise, an Err
is returned with the same Rc
that was\npassed in.
This will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
pub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
Otherwise, None
is returned and the Rc
is dropped.
This will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
Rc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
source§impl<T> Serialize for Rc<T>
impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
Serializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
source§impl<T> ToTokens for Rc<T>
impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
impl<T, A> DerefPure for Rc<T, A>
impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
impl<T, A> Eq for Rc<T, A>
impl<T, A> PinCoerceUnsized for Rc<T, A>
impl<T, A> RefUnwindSafe for Rc<T, A>
impl<T, A> !Send for Rc<T, A>
impl<T, A> !Sync for Rc<T, A>
impl<T, A> Unpin for Rc<T, A>
impl<T, A> UnwindSafe for Rc<T, A>
1.69.0 · source§impl<T> AsFd for Rc<T>
impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
1.0.0 · source§impl<T, A> Clone for Rc<T, A>
impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
This creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'de, T> Deserialize<'de> for Rc<T>
impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
Deserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
1.0.0 · source§impl<T, A> Drop for Rc<T, A>
impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
fn drop(&mut self)
Drops the Rc
.
This will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
1.0.0 · source§impl<T, A> Ord for Rc<T, A>
impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
The two are compared by calling cmp()
on their inner values.
§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
fn max(self, other: Self) -> Selfwhere\n Self: Sized,
1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
Two Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
If T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
source§fn ne(&self, other: &Rc<T, A>) -> bool
fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
Two Rc
s are not equal if their inner values are not equal.
If T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
The two are compared by calling partial_cmp()
on their inner values.
§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
source§fn lt(&self, other: &Rc<T, A>) -> bool
fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
The two are compared by calling <
on their inner values.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
source§fn le(&self, other: &Rc<T, A>) -> bool
fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
The two are compared by calling <=
on their inner values.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
source§impl<T> Rc<T>where\n T: ?Sized,
impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
pub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
The raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
- \n
- If
U
is sized, it must have the same size and alignment asT
. This\nis trivially true ifU
isT
. \n - If
U
is unsized, its data pointer must have the same size and\nalignment asT
. This is trivially true ifRc<U>
was constructed\nthroughRc<T>
and then converted toRc<U>
through an unsized\ncoercion. \n
Note that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
The raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
This function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Convert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
pub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
pub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
source§impl<T> Rc<T>
impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
pub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
Generally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
new_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
Since the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
pub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
sourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
pub fn new_zeroed() -> Rc<MaybeUninit<T>>
new_zeroed_alloc
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
sourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new(value: T) -> Result<Rc<T>, AllocError>
allocator_api
)Constructs a new Rc<T>
, returning an error if the allocation fails
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
sourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
sourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn allocator(this: &Rc<T, A>) -> &A
allocator_api
)Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
pub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
To avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
sourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
allocator_api
)Consumes the Rc
, returning the wrapped pointer and allocator.
To avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
pub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
sourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
allocator_api
)Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
The raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
- \n
- If
U
is sized, it must have the same size and alignment asT
. This\nis trivially true ifU
isT
. \n - If
U
is unsized, its data pointer must have the same size and\nalignment asT
. This is trivially true ifRc<U>
was constructed\nthroughRc<T>
and then converted toRc<U>
through an unsized\ncoercion. \n
Note that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
The raw pointer must point to a block of memory allocated by alloc
The user of from_raw
has to make sure a specific value of T
is only\ndropped once.
This function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Convert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
pub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
pub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
sourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
allocator_api
)Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
sourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
allocator_api
)Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
pub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
Returns None
otherwise, because it is not safe to\nmutate a shared value.
See also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
sourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
pub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
get_mut_unchecked
)Returns a mutable reference into the given Rc
,\nwithout any check.
See also get_mut
, which is safe and does appropriate checks.
§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
Other Rc
pointers to the same allocation must be to the same type.
#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
Other Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
pub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
pub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
If there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
However, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
See also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
Weak
pointers will be disassociated:
use std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
pub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
Assuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
source§impl<T, A> Rc<T, A>where\n A: Allocator,
impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_in(value: T, alloc: A) -> Rc<T, A>
allocator_api
)Constructs a new Rc
in the provided allocator.
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
sourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
allocator_api
)Constructs a new Rc
with uninitialized contents in the provided allocator.
§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
sourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
sourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
allocator_api
)Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
sourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
sourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
sourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
allocator_api
)Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
pub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
Otherwise, an Err
is returned with the same Rc
that was\npassed in.
This will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
pub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
Otherwise, None
is returned and the Rc
is dropped.
This will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
Rc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
source§impl<T> Serialize for Rc<T>
impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
Serializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
source§impl<T> ToTokens for Rc<T>
impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
impl<T, A> DerefPure for Rc<T, A>
impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
impl<T, A> Eq for Rc<T, A>
impl<T, A> PinCoerceUnsized for Rc<T, A>
impl<T, A> RefUnwindSafe for Rc<T, A>
impl<T, A> !Send for Rc<T, A>
impl<T, A> !Sync for Rc<T, A>
impl<T, A> Unpin for Rc<T, A>
impl<T, A> UnwindSafe for Rc<T, A>
1.69.0 · source§impl<T> AsFd for Rc<T>
impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
1.0.0 · source§impl<T, A> Clone for Rc<T, A>
impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
This creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'de, T> Deserialize<'de> for Rc<T>
impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
Deserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
1.0.0 · source§impl<T, A> Drop for Rc<T, A>
impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
fn drop(&mut self)
Drops the Rc
.
This will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
1.0.0 · source§impl<T, A> Ord for Rc<T, A>
impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
The two are compared by calling cmp()
on their inner values.
§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
fn max(self, other: Self) -> Selfwhere\n Self: Sized,
1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
Two Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
If T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
source§fn ne(&self, other: &Rc<T, A>) -> bool
fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
Two Rc
s are not equal if their inner values are not equal.
If T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
The two are compared by calling partial_cmp()
on their inner values.
§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
source§fn lt(&self, other: &Rc<T, A>) -> bool
fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
The two are compared by calling <
on their inner values.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
source§fn le(&self, other: &Rc<T, A>) -> bool
fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
The two are compared by calling <=
on their inner values.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
source§impl<T> Rc<T>where\n T: ?Sized,
impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
pub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
The raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
- \n
- If
U
is sized, it must have the same size and alignment asT
. This\nis trivially true ifU
isT
. \n - If
U
is unsized, its data pointer must have the same size and\nalignment asT
. This is trivially true ifRc<U>
was constructed\nthroughRc<T>
and then converted toRc<U>
through an unsized\ncoercion. \n
Note that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
The raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
This function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Convert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
pub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
pub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
source§impl<T> Rc<T>
impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
pub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
Generally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
new_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
Since the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
pub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
sourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
pub fn new_zeroed() -> Rc<MaybeUninit<T>>
new_zeroed_alloc
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
sourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new(value: T) -> Result<Rc<T>, AllocError>
allocator_api
)Constructs a new Rc<T>
, returning an error if the allocation fails
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
sourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
sourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn allocator(this: &Rc<T, A>) -> &A
allocator_api
)Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
pub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
To avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
sourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
allocator_api
)Consumes the Rc
, returning the wrapped pointer and allocator.
To avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
pub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
sourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
allocator_api
)Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
The raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
- \n
- If
U
is sized, it must have the same size and alignment asT
. This\nis trivially true ifU
isT
. \n - If
U
is unsized, its data pointer must have the same size and\nalignment asT
. This is trivially true ifRc<U>
was constructed\nthroughRc<T>
and then converted toRc<U>
through an unsized\ncoercion. \n
Note that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
The raw pointer must point to a block of memory allocated by alloc
The user of from_raw
has to make sure a specific value of T
is only\ndropped once.
This function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Convert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
pub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
pub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
sourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
allocator_api
)Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
sourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
allocator_api
)Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
pub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
Returns None
otherwise, because it is not safe to\nmutate a shared value.
See also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
sourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
pub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
get_mut_unchecked
)Returns a mutable reference into the given Rc
,\nwithout any check.
See also get_mut
, which is safe and does appropriate checks.
§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
Other Rc
pointers to the same allocation must be to the same type.
#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
Other Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
pub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
pub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
If there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
However, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
See also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
Weak
pointers will be disassociated:
use std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
pub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
Assuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
source§impl<T, A> Rc<T, A>where\n A: Allocator,
impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_in(value: T, alloc: A) -> Rc<T, A>
allocator_api
)Constructs a new Rc
in the provided allocator.
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
sourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
allocator_api
)Constructs a new Rc
with uninitialized contents in the provided allocator.
§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
sourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
sourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
allocator_api
)Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
sourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
sourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
sourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
allocator_api
)Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
pub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
Otherwise, an Err
is returned with the same Rc
that was\npassed in.
This will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
pub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
Otherwise, None
is returned and the Rc
is dropped.
This will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
Rc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
source§impl<T> Serialize for Rc<T>
impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
Serializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
source§impl<T> ToTokens for Rc<T>
impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
impl<T, A> DerefPure for Rc<T, A>
impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
impl<T, A> Eq for Rc<T, A>
impl<T, A> PinCoerceUnsized for Rc<T, A>
impl<T, A> RefUnwindSafe for Rc<T, A>
impl<T, A> !Send for Rc<T, A>
impl<T, A> !Sync for Rc<T, A>
impl<T, A> Unpin for Rc<T, A>
impl<T, A> UnwindSafe for Rc<T, A>
1.69.0 · source§impl<T> AsFd for Rc<T>
impl<T> AsFd for Rc<T>
source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
1.0.0 · source§impl<T, A> Clone for Rc<T, A>
impl<T, A> Clone for Rc<T, A>
source§fn clone(&self) -> Rc<T, A>
fn clone(&self) -> Rc<T, A>
Makes a clone of the Rc
pointer.
This creates another pointer to the same allocation, increasing the\nstrong reference count.
\n§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nlet _ = Rc::clone(&five);
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'de, T> Deserialize<'de> for Rc<T>
impl<'de, T> Deserialize<'de> for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
Deserializing a data structure containing Rc
will not attempt to\ndeduplicate Rc
references to the same data. Every deserialized Rc
\nwill end up with a strong count of 1.
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
fn deserialize<D>(\n deserializer: D,\n) -> Result<Rc<T>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
1.0.0 · source§impl<T, A> Drop for Rc<T, A>
impl<T, A> Drop for Rc<T, A>
source§fn drop(&mut self)
fn drop(&mut self)
Drops the Rc
.
This will decrement the strong reference count. If the strong reference\ncount reaches zero then the only other references (if any) are\nWeak
, so we drop
the inner value.
§Examples
\nuse std::rc::Rc;\n\nstruct Foo;\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"dropped!\");\n }\n}\n\nlet foo = Rc::new(Foo);\nlet foo2 = Rc::clone(&foo);\n\ndrop(foo); // Doesn't print anything\ndrop(foo2); // Prints \"dropped!\"
1.0.0 · source§impl<T, A> Ord for Rc<T, A>
impl<T, A> Ord for Rc<T, A>
source§fn cmp(&self, other: &Rc<T, A>) -> Ordering
fn cmp(&self, other: &Rc<T, A>) -> Ordering
Comparison for two Rc
s.
The two are compared by calling cmp()
on their inner values.
§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Ordering::Less, five.cmp(&Rc::new(6)));
1.21.0 · source§fn max(self, other: Self) -> Selfwhere\n Self: Sized,
fn max(self, other: Self) -> Selfwhere\n Self: Sized,
1.0.0 · source§impl<T, A> PartialEq for Rc<T, A>
impl<T, A> PartialEq for Rc<T, A>
source§fn eq(&self, other: &Rc<T, A>) -> bool
fn eq(&self, other: &Rc<T, A>) -> bool
Equality for two Rc
s.
Two Rc
s are equal if their inner values are equal, even if they are\nstored in different allocation.
If T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five == Rc::new(5));
source§fn ne(&self, other: &Rc<T, A>) -> bool
fn ne(&self, other: &Rc<T, A>) -> bool
Inequality for two Rc
s.
Two Rc
s are not equal if their inner values are not equal.
If T
also implements Eq
(implying reflexivity of equality),\ntwo Rc
s that point to the same allocation are\nalways equal.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five != Rc::new(6));
1.0.0 · source§impl<T, A> PartialOrd for Rc<T, A>
impl<T, A> PartialOrd for Rc<T, A>
source§fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
fn partial_cmp(&self, other: &Rc<T, A>) -> Option<Ordering>
Partial comparison for two Rc
s.
The two are compared by calling partial_cmp()
on their inner values.
§Examples
\nuse std::rc::Rc;\nuse std::cmp::Ordering;\n\nlet five = Rc::new(5);\n\nassert_eq!(Some(Ordering::Less), five.partial_cmp(&Rc::new(6)));
source§fn lt(&self, other: &Rc<T, A>) -> bool
fn lt(&self, other: &Rc<T, A>) -> bool
Less-than comparison for two Rc
s.
The two are compared by calling <
on their inner values.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five < Rc::new(6));
source§fn le(&self, other: &Rc<T, A>) -> bool
fn le(&self, other: &Rc<T, A>) -> bool
‘Less than or equal to’ comparison for two Rc
s.
The two are compared by calling <=
on their inner values.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nassert!(five <= Rc::new(5));
source§impl<T> Rc<T>where\n T: ?Sized,
impl<T> Rc<T>where\n T: ?Sized,
1.17.0 · sourcepub unsafe fn from_raw(ptr: *const T) -> Rc<T>
pub unsafe fn from_raw(ptr: *const T) -> Rc<T>
Constructs an Rc<T>
from a raw pointer.
The raw pointer must have been previously returned by a call to\nRc<U>::into_raw
with the following requirements:
- \n
- If
U
is sized, it must have the same size and alignment asT
. This\nis trivially true ifU
isT
. \n - If
U
is unsized, its data pointer must have the same size and\nalignment asT
. This is trivially true ifRc<U>
was constructed\nthroughRc<T>
and then converted toRc<U>
through an unsized\ncoercion. \n
Note that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
The raw pointer must point to a block of memory allocated by the global allocator
\nThe user of from_raw
has to make sure a specific value of T
is only\ndropped once.
This function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw(x_ptr);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Convert a slice back into its original array:
\n\nuse std::rc::Rc;\n\nlet x: Rc<[u32]> = Rc::new([1, 2, 3]);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3]> = Rc::from_raw(x_ptr.cast::<[u32; 3]>());\n assert_eq!(&*x, &[1, 2, 3]);\n}
1.53.0 · sourcepub unsafe fn increment_strong_count(ptr: *const T)
pub unsafe fn increment_strong_count(ptr: *const T)
Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by the global allocator.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n}
1.53.0 · sourcepub unsafe fn decrement_strong_count(ptr: *const T)
pub unsafe fn decrement_strong_count(ptr: *const T)
Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by the global allocator. This method can be used to release the final Rc
and\nbacking storage, but should not be called after the final Rc
has been released.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count(ptr);\n\n let five = Rc::from_raw(ptr);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count(ptr);\n assert_eq!(1, Rc::strong_count(&five));\n}
source§impl<T> Rc<T>
impl<T> Rc<T>
1.60.0 · sourcepub fn new_cyclic<F>(data_fn: F) -> Rc<T>
pub fn new_cyclic<F>(data_fn: F) -> Rc<T>
Constructs a new Rc<T>
while giving you a Weak<T>
to the allocation,\nto allow you to construct a T
which holds a weak pointer to itself.
Generally, a structure circularly referencing itself, either directly or\nindirectly, should not hold a strong reference to itself to prevent a memory leak.\nUsing this function, you get access to the weak pointer during the\ninitialization of T
, before the Rc<T>
is created, such that you can\nclone and store it inside the T
.
new_cyclic
first allocates the managed allocation for the Rc<T>
,\nthen calls your closure, giving it a Weak<T>
to this allocation,\nand only afterwards completes the construction of the Rc<T>
by placing\nthe T
returned from your closure into the allocation.
Since the new Rc<T>
is not fully-constructed until Rc<T>::new_cyclic
\nreturns, calling upgrade
on the weak reference inside your closure will\nfail and result in a None
value.
§Panics
\nIf data_fn
panics, the panic is propagated to the caller, and the\ntemporary Weak<T>
is dropped normally.
§Examples
\nuse std::rc::{Rc, Weak};\n\nstruct Gadget {\n me: Weak<Gadget>,\n}\n\nimpl Gadget {\n /// Constructs a reference counted Gadget.\n fn new() -> Rc<Self> {\n // `me` is a `Weak<Gadget>` pointing at the new allocation of the\n // `Rc` we're constructing.\n Rc::new_cyclic(|me| {\n // Create the actual struct here.\n Gadget { me: me.clone() }\n })\n }\n\n /// Returns a reference counted pointer to Self.\n fn me(&self) -> Rc<Self> {\n self.me.upgrade().unwrap()\n }\n}
1.83.0 · sourcepub fn new_uninit() -> Rc<MaybeUninit<T>>
pub fn new_uninit() -> Rc<MaybeUninit<T>>
Constructs a new Rc
with uninitialized contents.
§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::new_uninit();\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5)
sourcepub fn new_zeroed() -> Rc<MaybeUninit<T>>
🔬This is a nightly-only experimental API. (new_zeroed_alloc
)
pub fn new_zeroed() -> Rc<MaybeUninit<T>>
new_zeroed_alloc
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes.
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(new_zeroed_alloc)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::new_zeroed();\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
sourcepub fn try_new(value: T) -> Result<Rc<T>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new(value: T) -> Result<Rc<T>, AllocError>
allocator_api
)Constructs a new Rc<T>
, returning an error if the allocation fails
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\n\nlet five = Rc::try_new(5);
sourcepub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_uninit() -> Result<Rc<MaybeUninit<T>>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, returning an error if the allocation fails
§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut five = Rc::<u32>::try_new_uninit()?;\n\n// Deferred initialization:\nRc::get_mut(&mut five).unwrap().write(5);\n\nlet five = unsafe { five.assume_init() };\n\nassert_eq!(*five, 5);
sourcepub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_zeroed() -> Result<Rc<MaybeUninit<T>>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, returning an error if the allocation fails
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\n\nlet zero = Rc::<u32>::try_new_zeroed()?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
sourcepub fn allocator(this: &Rc<T, A>) -> &A
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn allocator(this: &Rc<T, A>) -> &A
allocator_api
)Returns a reference to the underlying allocator.
\nNote: this is an associated function, which means that you have\nto call it as Rc::allocator(&r)
instead of r.allocator()
. This\nis so that there is no conflict with a method on the inner type.
1.17.0 · sourcepub fn into_raw(this: Rc<T, A>) -> *const T
pub fn into_raw(this: Rc<T, A>) -> *const T
Consumes the Rc
, returning the wrapped pointer.
To avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw
.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet x_ptr = Rc::into_raw(x);\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
sourcepub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn into_raw_with_allocator(this: Rc<T, A>) -> (*const T, A)
allocator_api
)Consumes the Rc
, returning the wrapped pointer and allocator.
To avoid a memory leak the pointer must be converted back to an Rc
using\nRc::from_raw_in
.
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet (ptr, alloc) = Rc::into_raw_with_allocator(x);\nassert_eq!(unsafe { &*ptr }, \"hello\");\nlet x = unsafe { Rc::from_raw_in(ptr, alloc) };\nassert_eq!(&*x, \"hello\");
1.45.0 · sourcepub fn as_ptr(this: &Rc<T, A>) -> *const T
pub fn as_ptr(this: &Rc<T, A>) -> *const T
Provides a raw pointer to the data.
\nThe counts are not affected in any way and the Rc
is not consumed. The pointer is valid\nfor as long there are strong counts in the Rc
.
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(\"hello\".to_owned());\nlet y = Rc::clone(&x);\nlet x_ptr = Rc::as_ptr(&x);\nassert_eq!(x_ptr, Rc::as_ptr(&y));\nassert_eq!(unsafe { &*x_ptr }, \"hello\");
sourcepub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Rc<T, A>
allocator_api
)Constructs an Rc<T, A>
from a raw pointer in the provided allocator.
The raw pointer must have been previously returned by a call to Rc<U, A>::into_raw
with the following requirements:
- \n
- If
U
is sized, it must have the same size and alignment asT
. This\nis trivially true ifU
isT
. \n - If
U
is unsized, its data pointer must have the same size and\nalignment asT
. This is trivially true ifRc<U>
was constructed\nthroughRc<T>
and then converted toRc<U>
through an unsized\ncoercion. \n
Note that if U
or U
’s data pointer is not T
but has the same size\nand alignment, this is basically like transmuting references of\ndifferent types. See mem::transmute
for more information\non what restrictions apply in this case.
The raw pointer must point to a block of memory allocated by alloc
The user of from_raw
has to make sure a specific value of T
is only\ndropped once.
This function is unsafe because improper use may lead to memory unsafety,\neven if the returned Rc<T>
is never accessed.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x = Rc::new_in(\"hello\".to_owned(), System);\nlet x_ptr = Rc::into_raw(x);\n\nunsafe {\n // Convert back to an `Rc` to prevent leak.\n let x = Rc::from_raw_in(x_ptr, System);\n assert_eq!(&*x, \"hello\");\n\n // Further calls to `Rc::from_raw(x_ptr)` would be memory-unsafe.\n}\n\n// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!
Convert a slice back into its original array:
\n\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet x: Rc<[u32], _> = Rc::new_in([1, 2, 3], System);\nlet x_ptr: *const [u32] = Rc::into_raw(x);\n\nunsafe {\n let x: Rc<[u32; 3], _> = Rc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);\n assert_eq!(&*x, &[1, 2, 3]);\n}
1.15.0 · sourcepub fn weak_count(this: &Rc<T, A>) -> usize
pub fn weak_count(this: &Rc<T, A>) -> usize
1.15.0 · sourcepub fn strong_count(this: &Rc<T, A>) -> usize
pub fn strong_count(this: &Rc<T, A>) -> usize
Gets the number of strong (Rc
) pointers to this allocation.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet _also_five = Rc::clone(&five);\n\nassert_eq!(2, Rc::strong_count(&five));
sourcepub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)where\n A: Clone,
allocator_api
)Increments the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) for the duration of this method, and ptr
must point to a block of memory\nallocated by alloc
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n}
sourcepub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
🔬This is a nightly-only experimental API. (allocator_api
)
pub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)
allocator_api
)Decrements the strong reference count on the Rc<T>
associated with the\nprovided pointer by one.
§Safety
\nThe pointer must have been obtained through Rc::into_raw
, the\nassociated Rc
instance must be valid (i.e. the strong count must be at\nleast 1) when invoking this method, and ptr
must point to a block of memory\nallocated by alloc
. This method can be used to release the final Rc
and backing storage,\nbut should not be called after the final Rc
has been released.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);\n\nunsafe {\n let ptr = Rc::into_raw(five);\n Rc::increment_strong_count_in(ptr, System);\n\n let five = Rc::from_raw_in(ptr, System);\n assert_eq!(2, Rc::strong_count(&five));\n Rc::decrement_strong_count_in(ptr, System);\n assert_eq!(1, Rc::strong_count(&five));\n}
1.4.0 · sourcepub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
pub fn get_mut(this: &mut Rc<T, A>) -> Option<&mut T>
Returns a mutable reference into the given Rc
, if there are\nno other Rc
or Weak
pointers to the same allocation.
Returns None
otherwise, because it is not safe to\nmutate a shared value.
See also make_mut
, which will clone
\nthe inner value when there are other Rc
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet mut x = Rc::new(3);\n*Rc::get_mut(&mut x).unwrap() = 4;\nassert_eq!(*x, 4);\n\nlet _y = Rc::clone(&x);\nassert!(Rc::get_mut(&mut x).is_none());
sourcepub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
🔬This is a nightly-only experimental API. (get_mut_unchecked
)
pub unsafe fn get_mut_unchecked(this: &mut Rc<T, A>) -> &mut T
get_mut_unchecked
)Returns a mutable reference into the given Rc
,\nwithout any check.
See also get_mut
, which is safe and does appropriate checks.
§Safety
\nIf any other Rc
or Weak
pointers to the same allocation exist, then\nthey must not be dereferenced or have active borrows for the duration\nof the returned borrow, and their inner type must be exactly the same as the\ninner type of this Rc (including lifetimes). This is trivially the case if no\nsuch pointers exist, for example immediately after Rc::new
.
§Examples
\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet mut x = Rc::new(String::new());\nunsafe {\n Rc::get_mut_unchecked(&mut x).push_str(\"foo\")\n}\nassert_eq!(*x, \"foo\");
Other Rc
pointers to the same allocation must be to the same type.
#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<str> = Rc::from(\"Hello, world!\");\nlet mut y: Rc<[u8]> = x.clone().into();\nunsafe {\n // this is Undefined Behavior, because x's inner type is str, not [u8]\n Rc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8\n}\nprintln!(\"{}\", &*x); // Invalid UTF-8 in a str
Other Rc
pointers to the same allocation must be to the exact same type, including lifetimes.
#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\n\nlet x: Rc<&str> = Rc::new(\"Hello, world!\");\n{\n let s = String::from(\"Oh, no!\");\n let mut y: Rc<&str> = x.clone().into();\n unsafe {\n // this is Undefined Behavior, because x's inner type\n // is &'long str, not &'short str\n *Rc::get_mut_unchecked(&mut y) = &s;\n }\n}\nprintln!(\"{}\", &*x); // Use-after-free
1.17.0 · sourcepub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
pub fn ptr_eq(this: &Rc<T, A>, other: &Rc<T, A>) -> bool
Returns true
if the two Rc
s point to the same allocation in a vein similar to\nptr::eq
. This function ignores the metadata of dyn Trait
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet five = Rc::new(5);\nlet same_five = Rc::clone(&five);\nlet other_five = Rc::new(5);\n\nassert!(Rc::ptr_eq(&five, &same_five));\nassert!(!Rc::ptr_eq(&five, &other_five));
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
1.4.0 · sourcepub fn make_mut(this: &mut Rc<T, A>) -> &mut T
pub fn make_mut(this: &mut Rc<T, A>) -> &mut T
Makes a mutable reference into the given Rc
.
If there are other Rc
pointers to the same allocation, then make_mut
will\nclone
the inner value to a new allocation to ensure unique ownership. This is also\nreferred to as clone-on-write.
However, if there are no other Rc
pointers to this allocation, but some Weak
\npointers, then the Weak
pointers will be disassociated and the inner value will not\nbe cloned.
See also get_mut
, which will fail rather than cloning the inner value\nor disassociating Weak
pointers.
§Examples
\nuse std::rc::Rc;\n\nlet mut data = Rc::new(5);\n\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\nlet mut other_data = Rc::clone(&data); // Won't clone inner data\n*Rc::make_mut(&mut data) += 1; // Clones inner data\n*Rc::make_mut(&mut data) += 1; // Won't clone anything\n*Rc::make_mut(&mut other_data) *= 2; // Won't clone anything\n\n// Now `data` and `other_data` point to different allocations.\nassert_eq!(*data, 8);\nassert_eq!(*other_data, 12);
Weak
pointers will be disassociated:
use std::rc::Rc;\n\nlet mut data = Rc::new(75);\nlet weak = Rc::downgrade(&data);\n\nassert!(75 == *data);\nassert!(75 == *weak.upgrade().unwrap());\n\n*Rc::make_mut(&mut data) += 1;\n\nassert!(76 == *data);\nassert!(weak.upgrade().is_none());
source§impl<T, A> Rc<T, A>
impl<T, A> Rc<T, A>
1.76.0 · sourcepub fn unwrap_or_clone(this: Rc<T, A>) -> T
pub fn unwrap_or_clone(this: Rc<T, A>) -> T
If we have the only reference to T
then unwrap it. Otherwise, clone T
and return the\nclone.
Assuming rc_t
is of type Rc<T>
, this function is functionally equivalent to\n(*rc_t).clone()
, but will avoid cloning the inner value where possible.
§Examples
\nlet inner = String::from(\"test\");\nlet ptr = inner.as_ptr();\n\nlet rc = Rc::new(inner);\nlet inner = Rc::unwrap_or_clone(rc);\n// The inner value was not cloned\nassert!(ptr::eq(ptr, inner.as_ptr()));\n\nlet rc = Rc::new(inner);\nlet rc2 = rc.clone();\nlet inner = Rc::unwrap_or_clone(rc);\n// Because there were 2 references, we had to clone the inner value.\nassert!(!ptr::eq(ptr, inner.as_ptr()));\n// `rc2` is the last reference, so when we unwrap it we get back\n// the original `String`.\nlet inner = Rc::unwrap_or_clone(rc2);\nassert!(ptr::eq(ptr, inner.as_ptr()));
source§impl<T, A> Rc<T, A>where\n A: Allocator,
impl<T, A> Rc<T, A>where\n A: Allocator,
sourcepub fn new_in(value: T, alloc: A) -> Rc<T, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_in(value: T, alloc: A) -> Rc<T, A>
allocator_api
)Constructs a new Rc
in the provided allocator.
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::new_in(5, System);
sourcepub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_uninit_in(alloc: A) -> Rc<MaybeUninit<T>, A>
allocator_api
)Constructs a new Rc
with uninitialized contents in the provided allocator.
§Examples
\n#![feature(get_mut_unchecked)]\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::new_uninit_in(System);\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5)
sourcepub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn new_zeroed_in(alloc: A) -> Rc<MaybeUninit<T>, A>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator.
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::new_zeroed_in(System);\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0)
sourcepub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_in(value: T, alloc: A) -> Result<Rc<T, A>, AllocError>
allocator_api
)Constructs a new Rc<T>
in the provided allocator, returning an error if the allocation\nfails
§Examples
\n#![feature(allocator_api)]\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet five = Rc::try_new_in(5, System);
sourcepub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_uninit_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, in the provided allocator, returning an\nerror if the allocation fails
§Examples
\n#![feature(allocator_api)]\n#![feature(get_mut_unchecked)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet mut five = Rc::<u32, _>::try_new_uninit_in(System)?;\n\nlet five = unsafe {\n // Deferred initialization:\n Rc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);\n\n five.assume_init()\n};\n\nassert_eq!(*five, 5);
sourcepub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn try_new_zeroed_in(alloc: A) -> Result<Rc<MaybeUninit<T>, A>, AllocError>
allocator_api
)Constructs a new Rc
with uninitialized contents, with the memory\nbeing filled with 0
bytes, in the provided allocator, returning an error if the allocation\nfails
See MaybeUninit::zeroed
for examples of correct and\nincorrect usage of this method.
§Examples
\n#![feature(allocator_api)]\n\nuse std::rc::Rc;\nuse std::alloc::System;\n\nlet zero = Rc::<u32, _>::try_new_zeroed_in(System)?;\nlet zero = unsafe { zero.assume_init() };\n\nassert_eq!(*zero, 0);
sourcepub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
🔬This is a nightly-only experimental API. (allocator_api
)
pub fn pin_in(value: T, alloc: A) -> Pin<Rc<T, A>>where\n A: 'static,
allocator_api
)Constructs a new Pin<Rc<T>>
in the provided allocator. If T
does not implement Unpin
, then\nvalue
will be pinned in memory and unable to be moved.
1.4.0 · sourcepub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
pub fn try_unwrap(this: Rc<T, A>) -> Result<T, Rc<T, A>>
Returns the inner value, if the Rc
has exactly one strong reference.
Otherwise, an Err
is returned with the same Rc
that was\npassed in.
This will succeed even if there are outstanding weak references.
\n§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::try_unwrap(x), Ok(3));\n\nlet x = Rc::new(4);\nlet _y = Rc::clone(&x);\nassert_eq!(*Rc::try_unwrap(x).unwrap_err(), 4);
1.70.0 · sourcepub fn into_inner(this: Rc<T, A>) -> Option<T>
pub fn into_inner(this: Rc<T, A>) -> Option<T>
Returns the inner value, if the Rc
has exactly one strong reference.
Otherwise, None
is returned and the Rc
is dropped.
This will succeed even if there are outstanding weak references.
\nIf Rc::into_inner
is called on every clone of this Rc
,\nit is guaranteed that exactly one of the calls returns the inner value.\nThis means in particular that the inner value is not dropped.
Rc::try_unwrap
is conceptually similar to Rc::into_inner
.\nAnd while they are meant for different use-cases, Rc::into_inner(this)
\nis in fact equivalent to Rc::try_unwrap(this).ok()
.\n(Note that the same kind of equivalence does not hold true for\nArc
, due to race conditions that do not apply to Rc
!)
§Examples
\nuse std::rc::Rc;\n\nlet x = Rc::new(3);\nassert_eq!(Rc::into_inner(x), Some(3));\n\nlet x = Rc::new(4);\nlet y = Rc::clone(&x);\n\nassert_eq!(Rc::into_inner(y), None);\nassert_eq!(Rc::into_inner(x), Some(4));
source§impl<T> Serialize for Rc<T>
impl<T> Serialize for Rc<T>
This impl requires the \"rc\"
Cargo feature of Serde.
Serializing a data structure containing Rc
will serialize a copy of\nthe contents of the Rc
each time the Rc
is referenced within the\ndata structure. Serialization will not attempt to deduplicate these\nrepeated data.
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
source§impl<T> ToTokens for Rc<T>
impl<T> ToTokens for Rc<T>
source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
source§fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere\n Self: Sized,
impl<T, U, A> CoerceUnsized<Rc<U, A>> for Rc<T, A>
impl<T, A> DerefPure for Rc<T, A>
impl<T, U> DispatchFromDyn<Rc<U>> for Rc<T>
impl<T, A> Eq for Rc<T, A>
impl<T, A> PinCoerceUnsized for Rc<T, A>
impl<T, A> RefUnwindSafe for Rc<T, A>
impl<T, A> !Send for Rc<T, A>
impl<T, A> !Sync for Rc<T, A>
impl<T, A> Unpin for Rc<T, A>
impl<T, A> UnwindSafe for Rc<T, A>
§impl<K, V> CollectionMut for HashMap<K, V>
impl<K, V> CollectionMut for HashMap<K, V>
source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
source§fn extend_one(&mut self, _: (&'a K, &'a V))
fn extend_one(&mut self, _: (&'a K, &'a V))
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
source§fn extend_one(&mut self, _: (K, V))
fn extend_one(&mut self, _: (K, V))
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
source§impl<K, V> HashMap<K, V>
impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
pub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
The hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
pub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
The hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
hash_raw_entry
)Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n- \n
- Hash memoization \n
- Deferring the creation of an owned key until it is known to be required \n
- Using a search key that doesn’t work with the Borrow trait \n
- Using custom comparison logic without newtype wrappers \n
Because raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
In particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
pub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
hash_raw_entry
)Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n- \n
- Hash memoization \n
- Using a search key that doesn’t work with the Borrow trait \n
- Using custom comparison logic without newtype wrappers \n
Unless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
Immutable raw entries have very limited use; you might instead want raw_entry_mut
.
source§impl<K, V, S> HashMap<K, V, S>
impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
The created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
The hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
The hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
Warning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
The hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
1.0.0 · sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
pub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
pub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
pub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
pub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
pub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
1.0.0 · sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
pub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
sourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
pub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
hash_extract_if
)Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
If the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
1.9.0 · sourcepub fn hasher(&self) -> &S
pub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
source§impl<K, V, S> HashMap<K, V, S>
impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
§Panics
\nPanics if the new allocation size overflows usize
.
§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
1.0.0 · sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
pub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
pub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
sourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
pub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
map_many_mut
)Attempts to get mutable references to N
values in the map at once.
Returns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
sourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
pub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
map_many_mut
)Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
Returns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
For a safe alternative see get_many_mut
.
§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
If the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
sourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
pub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
map_try_insert
)Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
pub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
type MapValue<NewVal> = HashMap<Key, NewVal>
Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
map_fn
.source§impl<K, V, H> Serialize for HashMap<K, V, H>
impl<K, V, H> Serialize for HashMap<K, V, H>
source§fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
fn serialize<S>(\n &self,\n serializer: S,\n) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where\n S: Serializer,
impl<K, V, S> Eq for HashMap<K, V, S>
impl<K, V, S> UnwindSafe for HashMap<K, V, S>
§impl<K, V> CollectionMut for HashMap<K, V>
impl<K, V> CollectionMut for HashMap<K, V>
source§impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
impl<'de, K, V, S> Deserialize<'de> for HashMap<K, V, S>
source§fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
fn deserialize<D>(\n deserializer: D,\n) -> Result<HashMap<K, V, S>, <D as Deserializer<'de>>::Error>where\n D: Deserializer<'de>,
1.4.0 · source§impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
impl<'a, K, V, S> Extend<(&'a K, &'a V)> for HashMap<K, V, S>
source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
source§fn extend_one(&mut self, _: (&'a K, &'a V))
fn extend_one(&mut self, _: (&'a K, &'a V))
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)1.0.0 · source§impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
Inserts all new key-values from the iterator and replaces values with existing\nkeys with new values returned from the iterator.
\nsource§fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
fn extend<T>(&mut self, iter: T)where\n T: IntoIterator<Item = (K, V)>,
source§fn extend_one(&mut self, _: (K, V))
fn extend_one(&mut self, _: (K, V))
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)1.0.0 · source§impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S>
source§impl<K, V> HashMap<K, V>
impl<K, V> HashMap<K, V>
1.0.0 · sourcepub fn new() -> HashMap<K, V>
pub fn new() -> HashMap<K, V>
Creates an empty HashMap
.
The hash map is initially created with a capacity of 0, so it will not allocate until it\nis first inserted into.
\n§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();
1.0.0 · sourcepub fn with_capacity(capacity: usize) -> HashMap<K, V>
pub fn with_capacity(capacity: usize) -> HashMap<K, V>
Creates an empty HashMap
with at least the specified capacity.
The hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
source§impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
impl<K, V, S> HashMap<K, V, S>where\n S: BuildHasher,
sourcepub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S>
hash_raw_entry
)Creates a raw entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched. After this, insertions into a vacant entry\nstill require an owned key to be provided.
\nRaw entries are useful for such exotic situations as:
\n- \n
- Hash memoization \n
- Deferring the creation of an owned key until it is known to be required \n
- Using a search key that doesn’t work with the Borrow trait \n
- Using custom comparison logic without newtype wrappers \n
Because raw entries provide much more low-level control, it’s much easier\nto put the HashMap into an inconsistent state which, while memory-safe,\nwill cause the map to produce seemingly random results. Higher-level and\nmore foolproof APIs like entry
should be preferred when possible.
In particular, the hash used to initialize the raw entry must still be\nconsistent with the hash of the key that is ultimately stored in the entry.\nThis is because implementations of HashMap may need to recompute hashes\nwhen resizing, at which point only the keys are available.
\nRaw entries give mutable access to the keys. This must not be used\nto modify how the key would compare or hash, as the map will not re-evaluate\nwhere the key should go, meaning the keys may become “lost” if their\nlocation does not reflect their state. For instance, if you change a key\nso that the map now contains keys which compare equal, search may start\nacting erratically, with two keys randomly masking each other. Implementations\nare free to assume this doesn’t happen (within the limits of memory-safety).
\nsourcepub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
🔬This is a nightly-only experimental API. (hash_raw_entry
)
pub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S>
hash_raw_entry
)Creates a raw immutable entry builder for the HashMap.
\nRaw entries provide the lowest level of control for searching and\nmanipulating a map. They must be manually initialized with a hash and\nthen manually searched.
\nThis is useful for
\n- \n
- Hash memoization \n
- Using a search key that doesn’t work with the Borrow trait \n
- Using custom comparison logic without newtype wrappers \n
Unless you are in such a situation, higher-level and more foolproof APIs like\nget
should be preferred.
Immutable raw entries have very limited use; you might instead want raw_entry_mut
.
source§impl<K, V, S> HashMap<K, V, S>
impl<K, V, S> HashMap<K, V, S>
1.7.0 (const: unstable) · sourcepub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S>
Creates an empty HashMap
which will use the given hash builder to hash\nkeys.
The created map has the default initial capacity.
\nWarning: hash_builder
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
The hash_builder
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_hasher(s);\nmap.insert(1, 2);
1.7.0 · sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashMap<K, V, S>
Creates an empty HashMap
with at least the specified capacity, using\nhasher
to hash the keys.
The hash map will be able to hold at least capacity
elements without\nreallocating. This method is allowed to allocate for more elements than\ncapacity
. If capacity
is 0, the hash map will not allocate.
Warning: hasher
is normally randomly generated, and\nis designed to allow HashMaps to be resistant to attacks that\ncause many collisions and very poor performance. Setting it\nmanually using this function can expose a DoS attack vector.
The hasher
passed should implement the BuildHasher
trait for\nthe HashMap to be useful, see its documentation for details.
§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet s = RandomState::new();\nlet mut map = HashMap::with_capacity_and_hasher(10, s);\nmap.insert(1, 2);
1.0.0 · sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
\nThis number is a lower bound; the HashMap<K, V>
might be able to hold\nmore, but is guaranteed to be able to hold at least this many.
§Examples
\nuse std::collections::HashMap;\nlet map: HashMap<i32, i32> = HashMap::with_capacity(100);\nassert!(map.capacity() >= 100);
1.0.0 · sourcepub fn keys(&self) -> Keys<'_, K, V>
pub fn keys(&self) -> Keys<'_, K, V>
An iterator visiting all keys in arbitrary order.\nThe iterator element type is &'a K
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor key in map.keys() {\n println!(\"{key}\");\n}
§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_keys(self) -> IntoKeys<K, V>
pub fn into_keys(self) -> IntoKeys<K, V>
Creates a consuming iterator visiting all the keys in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is K
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<&str> = map.into_keys().collect();\n// The `IntoKeys` iterator produces keys in arbitrary order, so the\n// keys must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [\"a\", \"b\", \"c\"]);
§Performance
\nIn the current implementation, iterating over keys takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn values(&self) -> Values<'_, K, V>
pub fn values(&self) -> Values<'_, K, V>
An iterator visiting all values in arbitrary order.\nThe iterator element type is &'a V
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values() {\n println!(\"{val}\");\n}
§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.10.0 · sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V>
An iterator visiting all values mutably in arbitrary order.\nThe iterator element type is &'a mut V
.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor val in map.values_mut() {\n *val = *val + 10;\n}\n\nfor val in map.values() {\n println!(\"{val}\");\n}
§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.54.0 · sourcepub fn into_values(self) -> IntoValues<K, V>
pub fn into_values(self) -> IntoValues<K, V>
Creates a consuming iterator visiting all the values in arbitrary order.\nThe map cannot be used after calling this.\nThe iterator element type is V
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nlet mut vec: Vec<i32> = map.into_values().collect();\n// The `IntoValues` iterator produces values in arbitrary order, so\n// the values must be sorted to test them against a sorted array.\nvec.sort_unstable();\nassert_eq!(vec, [1, 2, 3]);
§Performance
\nIn the current implementation, iterating over values takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter(&self) -> Iter<'_, K, V>
pub fn iter(&self) -> Iter<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order.\nThe iterator element type is (&'a K, &'a V)
.
§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\nfor (key, val) in map.iter() {\n println!(\"key: {key} val: {val}\");\n}
§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V>
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>
An iterator visiting all key-value pairs in arbitrary order,\nwith mutable references to the values.\nThe iterator element type is (&'a K, &'a mut V)
.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Update all values\nfor (_, val) in map.iter_mut() {\n *val *= 2;\n}\n\nfor (key, val) in &map {\n println!(\"key: {key} val: {val}\");\n}
§Performance
\nIn the current implementation, iterating over map takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the map.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert_eq!(a.len(), 0);\na.insert(1, \"a\");\nassert_eq!(a.len(), 1);
1.0.0 · sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the map contains no elements.
§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\nassert!(a.is_empty());\na.insert(1, \"a\");\nassert!(!a.is_empty());
1.6.0 · sourcepub fn drain(&mut self) -> Drain<'_, K, V>
pub fn drain(&mut self) -> Drain<'_, K, V>
Clears the map, returning all key-value pairs as an iterator. Keeps the\nallocated memory for reuse.
\nIf the returned iterator is dropped before being fully consumed, it\ndrops the remaining key-value pairs. The returned iterator keeps a\nmutable borrow on the map to optimize its implementation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.insert(2, \"b\");\n\nfor (k, v) in a.drain().take(1) {\n assert!(k == 1 || k == 2);\n assert!(v == \"a\" || v == \"b\");\n}\n\nassert!(a.is_empty());
sourcepub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
🔬This is a nightly-only experimental API. (hash_extract_if
)
pub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F>
hash_extract_if
)Creates an iterator which uses a closure to determine if an element should be removed.
\nIf the closure returns true, the element is removed from the map and yielded.\nIf the closure returns false, or panics, the element remains in the map and will not be\nyielded.
\nNote that extract_if
lets you mutate every value in the filter closure, regardless of\nwhether you choose to keep or remove it.
If the returned ExtractIf
is not exhausted, e.g. because it is dropped without iterating\nor the iteration short-circuits, then the remaining elements will be retained.\nUse retain
with a negated predicate if you do not need the returned iterator.
§Examples
\nSplitting a map into even and odd keys, reusing the original map:
\n\n#![feature(hash_extract_if)]\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x)).collect();\nlet extracted: HashMap<i32, i32> = map.extract_if(|k, _v| k % 2 == 0).collect();\n\nlet mut evens = extracted.keys().copied().collect::<Vec<_>>();\nlet mut odds = map.keys().copied().collect::<Vec<_>>();\nevens.sort();\nodds.sort();\n\nassert_eq!(evens, vec![0, 2, 4, 6]);\nassert_eq!(odds, vec![1, 3, 5, 7]);
1.18.0 · sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
\nIn other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
.\nThe elements are visited in unsorted (and unspecified) order.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();\nmap.retain(|&k, _| k % 2 == 0);\nassert_eq!(map.len(), 4);
§Performance
\nIn the current implementation, this operation takes O(capacity) time\ninstead of O(len) because it internally visits empty buckets too.
\n1.0.0 · sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory\nfor reuse.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut a = HashMap::new();\na.insert(1, \"a\");\na.clear();\nassert!(a.is_empty());
1.9.0 · sourcepub fn hasher(&self) -> &S
pub fn hasher(&self) -> &S
Returns a reference to the map’s BuildHasher
.
§Examples
\nuse std::collections::HashMap;\nuse std::hash::RandomState;\n\nlet hasher = RandomState::new();\nlet map: HashMap<i32, i32> = HashMap::with_hasher(hasher);\nlet hasher: &RandomState = map.hasher();
source§impl<K, V, S> HashMap<K, V, S>
impl<K, V, S> HashMap<K, V, S>
1.0.0 · sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling reserve
,\ncapacity will be greater than or equal to self.len() + additional
.\nDoes nothing if capacity is already sufficient.
§Panics
\nPanics if the new allocation size overflows usize
.
§Examples
\nuse std::collections::HashMap;\nlet mut map: HashMap<&str, i32> = HashMap::new();\nmap.reserve(10);
1.57.0 · sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted\nin the HashMap
. The collection may reserve more space to speculatively\navoid frequent reallocations. After calling try_reserve
,\ncapacity will be greater than or equal to self.len() + additional
if\nit returns Ok(())
.\nDoes nothing if capacity is already sufficient.
§Errors
\nIf the capacity overflows, or the allocator reports a failure, then an error\nis returned.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<&str, isize> = HashMap::new();\nmap.try_reserve(10).expect(\"why is the test harness OOMing on a handful of bytes?\");
1.0.0 · sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop\ndown as much as possible while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to_fit();\nassert!(map.capacity() >= 2);
1.56.0 · sourcepub fn shrink_to(&mut self, min_capacity: usize)
pub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop\ndown no lower than the supplied limit while maintaining the internal rules\nand possibly leaving some space in accordance with the resize policy.
\nIf the current capacity is less than the lower limit, this is a no-op.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut map: HashMap<i32, i32> = HashMap::with_capacity(100);\nmap.insert(1, 2);\nmap.insert(3, 4);\nassert!(map.capacity() >= 100);\nmap.shrink_to(10);\nassert!(map.capacity() >= 10);\nmap.shrink_to(0);\nassert!(map.capacity() >= 2);
1.0.0 · sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
pub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the given key’s corresponding entry in the map for in-place manipulation.
\n§Examples
\nuse std::collections::HashMap;\n\nlet mut letters = HashMap::new();\n\nfor ch in \"a short treatise on fungi\".chars() {\n letters.entry(ch).and_modify(|counter| *counter += 1).or_insert(1);\n}\n\nassert_eq!(letters[&'s'], 2);\nassert_eq!(letters[&'t'], 3);\nassert_eq!(letters[&'u'], 1);\nassert_eq!(letters.get(&'y'), None);
1.0.0 · sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get(&1), Some(&\"a\"));\nassert_eq!(map.get(&2), None);
1.40.0 · sourcepub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
Returns the key-value pair corresponding to the supplied key.
\nThe supplied key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.get_key_value(&1), Some((&1, &\"a\")));\nassert_eq!(map.get_key_value(&2), None);
sourcepub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
pub fn get_many_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
map_many_mut
)Attempts to get mutable references to N
values in the map at once.
Returns an array of length N
with the results of each query. For soundness, at most one\nmutable reference will be returned to any value. None
will be returned if any of the\nkeys are duplicates or missing.
§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);\n\n// Duplicate keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Athenæum\",\n]);\nassert_eq!(got, None);
sourcepub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
🔬This is a nightly-only experimental API. (map_many_mut
)
pub unsafe fn get_many_unchecked_mut<Q, const N: usize>(\n &mut self,\n ks: [&Q; N],\n) -> Option<[&mut V; N]>
map_many_mut
)Attempts to get mutable references to N
values in the map at once, without validating that\nthe values are unique.
Returns an array of length N
with the results of each query. None
will be returned if\nany of the keys are missing.
For a safe alternative see get_many_mut
.
§Safety
\nCalling this method with overlapping keys is undefined behavior even if the resulting\nreferences are not used.
\n§Examples
\n#![feature(map_many_mut)]\nuse std::collections::HashMap;\n\nlet mut libraries = HashMap::new();\nlibraries.insert(\"Bodleian Library\".to_string(), 1602);\nlibraries.insert(\"Athenæum\".to_string(), 1807);\nlibraries.insert(\"Herzogin-Anna-Amalia-Bibliothek\".to_string(), 1691);\nlibraries.insert(\"Library of Congress\".to_string(), 1800);\n\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"Library of Congress\",\n]);\nassert_eq!(\n got,\n Some([\n &mut 1807,\n &mut 1800,\n ]),\n);\n\n// Missing keys result in None\nlet got = libraries.get_many_mut([\n \"Athenæum\",\n \"New York Public Library\",\n]);\nassert_eq!(got, None);
1.0.0 · sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.contains_key(&1), true);\nassert_eq!(map.contains_key(&2), false);
1.0.0 · sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nif let Some(x) = map.get_mut(&1) {\n *x = \"b\";\n}\nassert_eq!(map[&1], \"b\");
1.0.0 · sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map.
\nIf the map did not have this key present, None
is returned.
If the map did have this key present, the value is updated, and the old\nvalue is returned. The key is not updated, though; this matters for\ntypes that can be ==
without being identical. See the module-level\ndocumentation for more.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.insert(37, \"a\"), None);\nassert_eq!(map.is_empty(), false);\n\nmap.insert(37, \"b\");\nassert_eq!(map.insert(37, \"c\"), Some(\"b\"));\nassert_eq!(map[&37], \"c\");
sourcepub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
🔬This is a nightly-only experimental API. (map_try_insert
)
pub fn try_insert(\n &mut self,\n key: K,\n value: V,\n) -> Result<&mut V, OccupiedError<'_, K, V>>
map_try_insert
)Tries to insert a key-value pair into the map, and returns\na mutable reference to the value in the entry.
\nIf the map already had this key present, nothing is updated, and\nan error containing the occupied entry and the value is returned.
\n§Examples
\nBasic usage:
\n\n#![feature(map_try_insert)]\n\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nassert_eq!(map.try_insert(37, \"a\").unwrap(), &\"a\");\n\nlet err = map.try_insert(37, \"b\").unwrap_err();\nassert_eq!(err.entry.key(), &37);\nassert_eq!(err.entry.get(), &\"a\");\nassert_eq!(err.value, \"b\");
1.0.0 · sourcepub fn remove<Q>(&mut self, k: &Q) -> Option<V>
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
Removes a key from the map, returning the value at the key if the key\nwas previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove(&1), Some(\"a\"));\nassert_eq!(map.remove(&1), None);
1.27.0 · sourcepub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
pub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(K, V)>
Removes a key from the map, returning the stored key and value if the\nkey was previously in the map.
\nThe key may be any borrowed form of the map’s key type, but\nHash
and Eq
on the borrowed form must match those for\nthe key type.
§Examples
\nuse std::collections::HashMap;\n\nlet mut map = HashMap::new();\nmap.insert(1, \"a\");\nassert_eq!(map.remove_entry(&1), Some((1, \"a\")));\nassert_eq!(map.remove(&1), None);
§impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
impl<K, V, S> HashMapExt for HashMap<K, V, S>where\n S: BuildHasher + Default,
source§impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>where\n K: IntoDeserializer<'de, E> + Eq + Hash,\n V: IntoDeserializer<'de, E>,\n S: BuildHasher,\n E: Error,
source§type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
type Deserializer = MapDeserializer<'de, <HashMap<K, V, S> as IntoIterator>::IntoIter, E>
source§fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
fn into_deserializer(\n self,\n) -> <HashMap<K, V, S> as IntoDeserializer<'de, E>>::Deserializer
1.0.0 · source§impl<K, V, S> IntoIterator for HashMap<K, V, S>
impl<K, V, S> IntoIterator for HashMap<K, V, S>
source§fn into_iter(self) -> IntoIter<K, V>
fn into_iter(self) -> IntoIter<K, V>
Creates a consuming iterator, that is, one that moves each key-value\npair out of the map in arbitrary order. The map cannot be used after\ncalling this.
\n§Examples
\nuse std::collections::HashMap;\n\nlet map = HashMap::from([\n (\"a\", 1),\n (\"b\", 2),\n (\"c\", 3),\n]);\n\n// Not possible with .iter()\nlet vec: Vec<(&str, i32)> = map.into_iter().collect();
§impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
impl<Key, OldVal> MapMapValues<OldVal> for HashMap<Key, OldVal>
§type MapValue<NewVal> = HashMap<Key, NewVal>
type MapValue<NewVal> = HashMap<Key, NewVal>
Self
but with OldVal
replaced with NewVal
.§fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
fn map_values<NewVal, MapFn>(\n self,\n map_fn: MapFn,\n) -> <HashMap<Key, OldVal> as MapMapValues<OldVal>>::MapValue<NewVal>where\n MapFn: FnMut(OldVal) -> NewVal,
map_fn
.