openharmony_ci ad855aa18c !4 merge master into master
once_cell新增bundle.json部件化

Created-by: dragonswordy
Commit-by: ljy9810
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)

https://gitcode.com/openharmony/third_party_rust_autocfg/issues/3

### 二、建议测试周期和提测地址  
  建议测试完成时间:xxxx.xx.xx  
  投产上线时间:xxxx.xx.xx  
  提测地址:CI环境/压测环境  
  测试账号:  

### 三、变更内容
  * 3.1 关联PR列表

  * 3.2 数据库和部署说明  
    1. 常规更新 
    2. 重启unicorn
    3. 重启sidekiq
    4. 迁移任务:是否有迁移任务,没有写 "无"
    5. rake脚本:`bundle exec xxx RAILS_ENV = production`;没有写 "无"

  * 3.4 其他技术优化内容(做了什么,变更了什么)
    - 重构了 xxxx 代码
    - xxxx 算法优化


  * 3.5 废弃通知(什么字段、方法弃用?)



  * 3.6  后向不兼容变更(是否有无法向后兼容的变更?)


  
### 四、研发自测点(自测哪些?冒烟用例全部自测?)
  自测测试结论:


### 五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方)
  检查点:

| 需求名称 | 是否影响xx公共模块 | 是否需要xx功能 | 需求升级是否依赖其他子产品 |
|------|------------|----------|---------------|
| xxx  | 否          | 需要       | 不需要           |
|      |            |          |               |

  接口测试:

  性能测试:

  并发测试:

  其他:



See merge request: openharmony/third_party_rust_once_cell!4
2025-12-31 22:05:34 +08:00
2022-11-25 15:39:59 +00:00
2018-08-08 16:05:57 +03:00
2022-08-22 16:20:14 +08:00
2022-12-28 23:58:56 -08:00
2022-10-22 19:25:26 +01:00
2022-11-25 15:39:59 +00:00
2020-08-17 23:01:48 +02:00
2020-11-11 01:38:33 +01:00
2025-12-24 09:39:33 +08:00
2022-09-16 00:10:20 +01:00
2022-12-28 23:58:56 -08:00
2022-12-28 23:58:56 -08:00
2018-08-02 03:12:28 +03:00
2018-08-02 03:12:28 +03:00
2018-08-08 16:05:57 +03:00
2023-04-14 14:15:14 +08:00
2022-11-10 15:02:43 +01:00
2019-09-01 14:25:59 +03:00

once_cell

Build Status Crates.io API reference

Overview

once_cell provides two new cell-like types, unsync::OnceCell and sync::OnceCell. OnceCell might store arbitrary non-Copy types, can be assigned to at most once and provide direct access to the stored contents. In a nutshell, API looks roughly like this:

impl OnceCell<T> {
    fn new() -> OnceCell<T> { ... }
    fn set(&self, value: T) -> Result<(), T> { ... }
    fn get(&self) -> Option<&T> { ... }
}

Note that, like with RefCell and Mutex, the set method requires only a shared reference. Because of the single assignment restriction get can return an &T instead of Ref<T> or MutexGuard<T>.

once_cell also has a Lazy<T> type, build on top of OnceCell which provides the same API as the lazy_static! macro, but without using any macros:

use std::{sync::Mutex, collections::HashMap};
use once_cell::sync::Lazy;

static GLOBAL_DATA: Lazy<Mutex<HashMap<i32, String>>> = Lazy::new(|| {
    let mut m = HashMap::new();
    m.insert(13, "Spica".to_string());
    m.insert(74, "Hoyten".to_string());
    Mutex::new(m)
});

fn main() {
    println!("{:?}", GLOBAL_DATA.lock().unwrap());
}

More patterns and use-cases are in the docs!

Related crates

The API of once_cell is being proposed for inclusion in std.

S
Description
提供一种在不使用互斥锁的情况下实现只初始化一次的单元格类型。 | A Rust library that provides a cell that can only be written to once.
Readme 1.7 MiB
Languages
Rust 100%