5 releases

0.1.10 Aug 17, 2024
0.1.5 Aug 6, 2024
0.1.4 Aug 6, 2024
0.1.3 Aug 6, 2024
0.1.2 Aug 6, 2024

#433 in Internationalization (i18n)

Download history 172/week @ 2024-07-31 113/week @ 2024-08-07 148/week @ 2024-08-14 9/week @ 2024-08-21

442 downloads per month

MulanPSL-2.0

6KB
68 lines

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 ⋅ 国际化解决方案 的开源组件。

No runtime deps