+25
| // This file is part of ICU4X. For terms of use, please see the file | ||
| // called LICENSE at the top level of the ICU4X source tree | ||
| // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). | ||
| use crate::Yokeable; | ||
| use core::mem; | ||
| /// This method casts `yokeable` between `&'a mut Y<'static>` and `&'a mut Y<'a>`, | ||
| /// and passes it to `f`. | ||
| /// | ||
| /// See [`Yokeable::transform_mut`] for why this is safe, noting that no `'static` return type | ||
| /// can leak data from the cart or Yokeable. | ||
| #[inline] | ||
| pub(crate) fn transform_mut_yokeable<'a, Y, F, R>(yokeable: &'a mut Y, f: F) -> R | ||
| where | ||
| Y: Yokeable<'a>, | ||
| // be VERY CAREFUL changing this signature, it is very nuanced | ||
| F: 'static + for<'b> FnOnce(&'b mut Y::Output) -> R, | ||
| R: 'static, | ||
| { | ||
| // Cast away the lifetime of `Y` | ||
| // Safety: this is equivalent to f(transmute(yokeable)), and the documentation of | ||
| // [`Yokeable::transform_mut`] and this function explain why doing so is sound. | ||
| unsafe { f(mem::transmute::<&'a mut Y, &'a mut Y::Output>(yokeable)) } | ||
| } |
| { | ||
| "git": { | ||
| "sha1": "f4290a877dfcb0f87cad6de4abdd65f0cbb33c9c" | ||
| "sha1": "29dfe2790b6cfdab94ca6a6b69f58ce54802dbf7" | ||
| }, | ||
| "path_in_vcs": "utils/yoke" | ||
| } |
+60
-27
@@ -16,11 +16,14 @@ # This file is automatically @generated by Cargo. | ||
| name = "cobs" | ||
| version = "0.2.3" | ||
| version = "0.3.0" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" | ||
| checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" | ||
| dependencies = [ | ||
| "thiserror", | ||
| ] | ||
| [[package]] | ||
| name = "postcard" | ||
| version = "1.1.1" | ||
| version = "1.1.3" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8" | ||
| checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" | ||
| dependencies = [ | ||
@@ -33,5 +36,5 @@ "cobs", | ||
| name = "proc-macro2" | ||
| version = "1.0.93" | ||
| version = "1.0.103" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" | ||
| checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" | ||
| dependencies = [ | ||
@@ -43,5 +46,5 @@ "unicode-ident", | ||
| name = "quote" | ||
| version = "1.0.38" | ||
| version = "1.0.41" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" | ||
| checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" | ||
| dependencies = [ | ||
@@ -53,6 +56,7 @@ "proc-macro2", | ||
| name = "serde" | ||
| version = "1.0.218" | ||
| version = "1.0.228" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" | ||
| checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" | ||
| dependencies = [ | ||
| "serde_core", | ||
| "serde_derive", | ||
@@ -62,6 +66,15 @@ ] | ||
| [[package]] | ||
| name = "serde_core" | ||
| version = "1.0.228" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" | ||
| dependencies = [ | ||
| "serde_derive", | ||
| ] | ||
| [[package]] | ||
| name = "serde_derive" | ||
| version = "1.0.218" | ||
| version = "1.0.228" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" | ||
| checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" | ||
| dependencies = [ | ||
@@ -75,11 +88,11 @@ "proc-macro2", | ||
| name = "stable_deref_trait" | ||
| version = "1.2.0" | ||
| version = "1.2.1" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" | ||
| checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" | ||
| [[package]] | ||
| name = "syn" | ||
| version = "2.0.98" | ||
| version = "2.0.108" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" | ||
| checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" | ||
| dependencies = [ | ||
@@ -93,5 +106,5 @@ "proc-macro2", | ||
| name = "synstructure" | ||
| version = "0.13.1" | ||
| version = "0.13.2" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" | ||
| checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" | ||
| dependencies = [ | ||
@@ -104,10 +117,30 @@ "proc-macro2", | ||
| [[package]] | ||
| name = "thiserror" | ||
| version = "2.0.17" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" | ||
| dependencies = [ | ||
| "thiserror-impl", | ||
| ] | ||
| [[package]] | ||
| name = "thiserror-impl" | ||
| version = "2.0.17" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" | ||
| dependencies = [ | ||
| "proc-macro2", | ||
| "quote", | ||
| "syn", | ||
| ] | ||
| [[package]] | ||
| name = "unicode-ident" | ||
| version = "1.0.17" | ||
| version = "1.0.20" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" | ||
| checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" | ||
| [[package]] | ||
| name = "yoke" | ||
| version = "0.8.0" | ||
| version = "0.8.1" | ||
| dependencies = [ | ||
@@ -124,5 +157,5 @@ "bincode", | ||
| name = "yoke-derive" | ||
| version = "0.8.0" | ||
| version = "0.8.1" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" | ||
| checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" | ||
| dependencies = [ | ||
@@ -137,5 +170,5 @@ "proc-macro2", | ||
| name = "zerofrom" | ||
| version = "0.1.5" | ||
| version = "0.1.6" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" | ||
| checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" | ||
| dependencies = [ | ||
@@ -147,5 +180,5 @@ "zerofrom-derive", | ||
| name = "zerofrom-derive" | ||
| version = "0.1.5" | ||
| version = "0.1.6" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" | ||
| checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" | ||
| dependencies = [ | ||
@@ -152,0 +185,0 @@ "proc-macro2", |
+9
-14
@@ -14,5 +14,5 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| edition = "2021" | ||
| rust-version = "1.81" | ||
| rust-version = "1.82" | ||
| name = "yoke" | ||
| version = "0.8.0" | ||
| version = "0.8.1" | ||
| authors = ["Manish Goregaokar <manishsmail@gmail.com>"] | ||
@@ -29,2 +29,3 @@ build = false | ||
| "README.md", | ||
| "build.rs", | ||
| ] | ||
@@ -54,4 +55,4 @@ autolib = false | ||
| [package.metadata.cargo-all-features] | ||
| max_combination_size = 3 | ||
| [package.metadata.workspaces] | ||
| independent = true | ||
@@ -61,4 +62,4 @@ [package.metadata.docs.rs] | ||
| [package.metadata.workspaces] | ||
| independent = true | ||
| [package.metadata.cargo-all-features] | ||
| max_combination_size = 3 | ||
@@ -68,3 +69,2 @@ [features] | ||
| "stable_deref_trait/alloc", | ||
| "serde?/alloc", | ||
| "zerofrom/alloc", | ||
@@ -80,3 +80,3 @@ ] | ||
| ] | ||
| serde = ["dep:serde"] | ||
| serde = [] | ||
| zerofrom = ["dep:zerofrom"] | ||
@@ -96,7 +96,2 @@ | ||
| [dependencies.serde] | ||
| version = "1.0.110" | ||
| optional = true | ||
| default-features = false | ||
| [dependencies.stable_deref_trait] | ||
@@ -124,3 +119,3 @@ version = "1.2.0" | ||
| [dev-dependencies.serde] | ||
| version = "1.0.110" | ||
| version = "1.0.220" | ||
| default-features = false |
+1
-0
@@ -55,2 +55,3 @@ // This file is part of ICU4X. For terms of use, please see the file | ||
| mod macro_impls; | ||
| mod utils; | ||
| mod yoke; | ||
@@ -57,0 +58,0 @@ mod yokeable; |
+2
-11
@@ -74,12 +74,3 @@ // This file is part of ICU4X. For terms of use, please see the file | ||
| /// unsafe fn make(from: Bar<'a>) -> Self { | ||
| /// // We're just doing mem::transmute() here, however Rust is | ||
| /// // not smart enough to realize that Bar<'a> and Bar<'static> are of | ||
| /// // the same size, so instead we use transmute_copy | ||
| /// | ||
| /// // This assert will be optimized out, but is included for additional | ||
| /// // peace of mind as we are using transmute_copy | ||
| /// debug_assert!(mem::size_of::<Bar<'a>>() == mem::size_of::<Self>()); | ||
| /// let ptr: *const Self = (&from as *const Self::Output).cast(); | ||
| /// mem::forget(from); | ||
| /// ptr::read(ptr) | ||
| /// unsafe { mem::transmute(from) } | ||
| /// } | ||
@@ -227,3 +218,3 @@ /// | ||
| /// | ||
| /// fn sound<'a>(foo: &'a mut Foo) { | ||
| /// fn sound(foo: &mut Foo) { | ||
| /// foo.cow.transform_mut(move |cow| cow.to_mut().push('a')); | ||
@@ -230,0 +221,0 @@ /// } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display