phper_alloc/
lib.rs

1// Copyright (c) 2022 PHPER Framework Team
2// PHPER is licensed under Mulan PSL v2.
3// You can use this software according to the terms and conditions of the Mulan
4// PSL v2. You may obtain a copy of Mulan PSL v2 at:
5//          http://license.coscl.org.cn/MulanPSL2
6// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
7// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
8// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9// See the Mulan PSL v2 for more details.
10
11#![warn(rust_2018_idioms, missing_docs)]
12#![warn(clippy::dbg_macro, clippy::print_stdout)]
13#![doc = include_str!("../README.md")]
14#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/112468984?s=200&v=4")]
15
16use std::borrow::Borrow;
17
18/// Duplicate an object without deep copy, but to only add the refcount, for php
19/// refcount struct.
20pub trait ToRefOwned {
21    /// The resulting type after obtaining ownership.
22    type Owned: Borrow<Self>;
23
24    /// Creates owned data from borrowed data, by increasing refcount.
25    fn to_ref_owned(&mut self) -> Self::Owned;
26}
27
28/// Duplicate an object without deep copy, but to only add the refcount, for php
29/// refcount struct.
30pub trait RefClone {
31    /// Returns a refcount value with same reference of the value.
32    fn ref_clone(&mut self) -> Self;
33}