Unified · Split
| @@ -1,7 +1,7 @@ | |||
| 1 | //! Immutable objects are read-only structures referencing most data from [a byte slice][crate::ObjectRef::from_bytes()]. | 1 | //! Immutable objects are read-only structures referencing most data from [a byte slice][crate::ObjectRef::from_bytes()]. |
| 2 | //! | 2 | //! |
| 3 | //! Immutable objects are expected to be deserialized from bytes that acts as backing store, and they | 3 | //! Immutable objects are expected to be deserialized from bytes that acts as backing store, and they |
| 4 | //! cannot be mutated or serialized. Instead, one will [convert][crate::ObjectRef::into_mutable()] them into their [`mutable`][crate::mutable] counterparts | 4 | //! cannot be mutated or serialized. Instead, one will [convert][crate::ObjectRef::into_owned()] them into their [`mutable`][crate::mutable] counterparts |
| 5 | //! which support mutation and serialization. | 5 | //! which support mutation and serialization. |
| 6 | 6 | ||
| 7 | /// | 7 | /// |
| @@ -14,14 +14,14 @@ impl<'a> ObjectRef<'a> { · 13 unmodified lines | |||
| 14 | /// Convert the signature_ref object into a mutable version, consuming the source in the process. | 14 | /// Convert the signature_ref object into a mutable version, consuming the source in the process. |
| 15 | /// | 15 | /// |
| 16 | /// Note that this is an expensive operation. | 16 | /// Note that this is an expensive operation. |
| 17 | pub fn into_mutable(self) -> Object { | 17 | pub fn into_owned(self) -> Object { |
| 18 | self.into() | 18 | self.into() |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | /// Convert this signature_ref object into its mutable counterpart. | 21 | /// Convert this signature_ref object into its mutable counterpart. |
| 22 | /// | 22 | /// |
| 23 | /// Note that this is an expensive operation. | 23 | /// Note that this is an expensive operation. |
| 24 | pub fn to_mutable(&self) -> Object { | 24 | pub fn to_owned(&self) -> Object { |
| 25 | self.clone().into() | 25 | self.clone().into() |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
| @@ -2,7 +2,7 @@ · 1 unmodified line | |||
| 2 | //! | 2 | //! |
| 3 | //! Mutable objects are Commits, Trees, Blobs and Tags that can be changed and serialized. | 3 | //! Mutable objects are Commits, Trees, Blobs and Tags that can be changed and serialized. |
| 4 | //! They either created using object [construction][crate::Object] or by [deserializing existing objects][crate::ObjectRef::from_bytes()] | 4 | //! They either created using object [construction][crate::Object] or by [deserializing existing objects][crate::ObjectRef::from_bytes()] |
| 5 | //! and converting these [into mutable copies][crate::ObjectRef::into_mutable()] for adjustments. | 5 | //! and converting these [into mutable copies][crate::ObjectRef::into_owned()] for adjustments. |
| 6 | 6 | ||
| 7 | pub(crate) const NL: &[u8; 1] = b"\n"; | 7 | pub(crate) const NL: &[u8; 1] = b"\n"; |
| 8 | pub(crate) const SPACE: &[u8; 1] = b" "; | 8 | pub(crate) const SPACE: &[u8; 1] = b" "; |
| @@ -26,7 +26,7 @@ impl<'a> Object<'a> { · 25 unmodified lines | |||
| 26 | /// conveniently. The cost of parsing an object is negligible. | 26 | /// conveniently. The cost of parsing an object is negligible. |
| 27 | /// | 27 | /// |
| 28 | /// **Note** that [mutable, decoded objects][git_object::Object] can be created from a [`crate::data::Object`] | 28 | /// **Note** that [mutable, decoded objects][git_object::Object] can be created from a [`crate::data::Object`] |
| 29 | /// using [`git_object::ObjectRef::into_mutable()`]. | 29 | /// using [`git_object::ObjectRef::into_owned()`]. |
| 30 | pub fn decode(&self) -> Result<ObjectRef<'a>, immutable::object::decode::Error> { | 30 | pub fn decode(&self) -> Result<ObjectRef<'a>, immutable::object::decode::Error> { |
| 31 | Ok(match self.kind { | 31 | Ok(match self.kind { |
| 32 | git_object::Kind::Tree => ObjectRef::Tree(TreeRef::from_bytes(self.data)?), | 32 | git_object::Kind::Tree => ObjectRef::Tree(TreeRef::from_bytes(self.data)?), |