pli

Crates.iopli
lib.rspli
version0.1.10
sourcesrc
created_at2024-08-06 05:55:41.662495
updated_at2024-08-17 13:51:09.044376
descriptionpli
homepagehttps://github.com/i18n-site/rust/tree/main/pli
repositoryhttps://github.com/i18n-site/rust.git
max_upload_size
id1326938
size6,321
i18n.site (i18nsite)

documentation

README

pli

use aok::Result;
use pli::Pli;
use static_init::constructor;

#[constructor(0)]
extern "C" fn init() {
  loginit::init()
}

#[test]
fn test() -> Result<()> {
  let mut txt_li = vec![
    "0 hello".to_string(),
    "1 world".to_string(),
    "2 rust".to_string(),
  ];
  let pos_li = vec![2, 0, 1];

  let mut li_proxy = Pli::new(&mut txt_li, pos_li);

  // 迭代
  for item in li_proxy.iter() {
    println!("{}", item);
  }
  // 访问和修改
  println!("{}", li_proxy[0]); // 输出 "rust"
  li_proxy[2] = "<".to_string();
  println!("{}", li_proxy[0]); // 输出 "Rust"

  {
    for (pos, mut i) in li_proxy.iter_mut().enumerate() {
      *i = "xx".into();
      if pos == 1 {
        break;
      }
    }
  }
  {
    dbg!(&txt_li);
  }
  Ok(())
}

About

This project is an open-source component of i18n.site ⋅ Internationalization Solution.

关于

本项目为 i18n.site ⋅ 国际化解决方案 的开源组件。

Commit count: 21

cargo fmt