RemoteFX Warning: You are currently using the RemoteFX 3D Video Adapter. ...
ãããåºããã
- 管çè
権éã§
powershell
ãå®è¡ Get-VMRemoteFXPhysicalVideoAdapter
ã³ãã³ãã§Enabled
ãTrue
ã«ãªã£ã¦ããããã¤ã¹ã®Name
ã確èªDisable-VMRemoteFXPhysicalVideoAdapter -Name "NVIDIA Geforce RTX 3090"
ã³ãã³ãã®ããã«(2)ã§ç¢ºèªããName
ãæå®ãã¦ããã¤ã¹ã® RemoteFX ãç¡å¹åGet-VMRemoteFXPhysicalVideoAdapter
ã³ãã³ãã§Enabled
ãFalse
ã«ãªã£ãã確èª
ä»äºä¸ã§ãã²ã¼ã ä¸ã§ãçªç¶ã«ç»é¢ã®çãä¸ã«è¦åãã¤ã¢ãã°ãåºã¦ãã¦æ¥µãã¦éªéã§ããOKãæ¼ãã¨ãã°ããåºã¦ããªãã®ã§å¿ãã¦ãã¾ããã¾ãçªç¶éªéãããäºæ ãç¹°ãè¿ã人ãå°ãªããªãããã
ãã©ãã¯ãã¼ã«ã Elecom M-DPT1MR ãã Kensington No. K72362JP Orbit Fusion ã¸æ¿ãã¦å¿«é©ã«ãªã£ãã¡ã¢
ãã¿ã¼ã«ã¹ãã¬ã¹ã«ãªã£ã¦ãã®ã§æ¿ãã¾ããï¼ãã¾ã®ã¨ããæ¿ãã¦ããã£ãã¨ããå°è±¡ã大ããã§ãð
æ°: Kensington No. K72362JP Orbit Fusion
ããã¨ãã
- æ¨æºä»æ§ã§å³ã¯ãªãã¯ãè¬æãåæã¨ããä½ç½®ã®ãã¿ã³ï¼(人差ãæã¨ä¸æã¯çã®æä½ã«å°å¿µã§ãã¾ãï¼)
- ã¹ã¯ãã¼ã«ãªã³ã°ä½¿ããããï¼(å®éã«ä½¿ãã¾ã§ã©ããªãã ããï¼ã£ã¦æã£ã¦ã¾ããã使ã£ã¦ã¿ããããã¯ãããã®ã§ãâ¦)
- 第3ãã¿ã³ãã¹ã¯ãã¼ã«ã¨ç¬ç«ãã¦ãã¦æ¼ãããæã«ã¹ãã¬ã¹ãªãæ¼ããï¼(ããã¦ãã®ã¹ã¯ãã¼ã«ãã¤ã¼ã«æ¹å¼ã®è£½åã§ã¯ãã¿ã³ãæ¼ãããã®ã«ã¹ã¯ãã¼ã«ãã¦ãã«ãããçºçããããã§ã)
- ãã¿ã³ãã£ã±ããã(5+DPIå¤æ´)
- çã®å¤§ããã大ãã
- æ¯æçã人工ã«ãã¼ã§èä¹ æ§ãé«ã(å ¬å¼SPECã«ã¯æ¸ãã¦ãªããã©ç®è¦å¤æã§ãã¶ã人工ã«ãã¼ãåèâ https://twitter.com/nekotrackball/status/1315996845152202753 )
- çã®æä½ã¯ã¨ã¦ããªããã(æç¶æ§ã¯é·ã使ããªãã¨ããããªã)
- ç¡ç·æ¥ç¶ã§ãã
- é»æ± ãAA(調éæ§ãä»ã®é»æ± æ©å¨ã¨ã®äºåé»æ± ã®å ±æãæãå³ãããã)
- Kensignton ãªã®ã«ã¡ããã¨å³ææä½ã«ç¹åããè¨è¨(å·¦å³å¯¾ç§°ã®ã£ãºãã¯å«ãªã®ã§ãâ¦åå²ãã¼ãã¼ãã®éã«ç½®ãã¦ä½¿ãã¨ããªããããããã®ããã ãã©)
ããããã¨ã¾ã§ã¯è¨ããªãããã©ã¡ãã£ã¨æ®å¿µãªã¨ãã
- æç·ã§æ¥ç¶ã§ããªã(é»æ± ã®æéã¨ééãå«ãªã®ã§ã)
- ã¹ã¯ãã¼ã«ãªã³ã°ãåãæ触ã«è»½ãã¶ã©ã¤ãããã(æä½ã«æ¯éã¯ç¡ãããã©æ¦ãé³ã¨æ触ããã¼ãã§æ®å¿µ)
- çãå¤ãã«ãã(ãæé¤ã®ã¨ãã¡ãã£ã¨æ°ã使ã)
æ§: Elecom M-DPT1MR ã«ã¤ãã¦
ããã¨æãã¦ããã¨ãã
- çã®å¤§ããã大ãã
- çã®æä½ã人差ãæï¼ä¸æ
- æ¯æçã人工ã«ãã¼ã§èä¹ æ§ãé«ã(å ¬å¼ã§äººå·¥ã«ãã¼ã¨è¨ã£ã¦ã)
- æç·æ¥ç¶ã§ãã
- ç¡ç·æ¥ç¶ãã§ãã
- ãã¿ã³ãã£ã±ããã(5+3)
- ãªãã5,000ååå¾ã§è²·ãã(ã¡ã¼ã«ã¼å¸æå°å£²ä¾¡æ ¼ã¯19,558å)
ãããã¨ãã (âæ¿ããçç±)
- æ¨æºä»æ§ã§ã¯å³ã¯ãªãã¯ãä¸æãåæã¨ããä½ç½®ã®ãã¿ã³
- ä¸æã¯äººå·®ãæã¨ã¨ãã«çã®æä½ã«ä½¿ãããã®ã§å³ã¯ãªãã¯æã«æãä¸æéæèãã¦åããå¿ è¦ããã£ã
- ãã¼ãã¦ã§ã¢çã« +3 ã®ãã¿ã³é¨åã¯åºæ¬ã® 5 ãã¿ã³ã¨éããåãå²ãå½ã¦ããã¦ãåå¿ããªãã¢ããªããã£ãããã¦ä¸ä¾¿
- è¬æã®ä½ç½®ã®ãã¿ã³ããã® +3 é¨åãªã®ã§ããã« Left, Right, Center ãªã©ã®ä½¿ç¨é »åº¦ã®å¤ããã¿ã³ãå²ãå½ã¦ãã¨åä½ããªãã¢ããªã«ééãã¦ã¹ãã¬ã¹ã«ãªãã¾ã
- Elecom Mouse Assistant ã£ã¦ããæºãã©ã¤ãã¼ã¿ãããªå
¬å¼ã®å¸¸é§ã¢ããªã使ãäºã§ãã¿ã³è¨å®ã¯ã«ã¹ã¿ãã¤ãºã§ããã®ã ãã©â¦ããã絶å¦ã«ä¸ä¾¿
- Windows ã Sleep ãã¦å¾©å¸°ãããã¨å¸¸é§ã¯ãã¦ãã¦ããã¿ã³ã®ã«ã¹ã¿ãã¤ãºã解ãã
- ã«ã¹ã¿ãã¤ãºã§å²ãå½ã¦ã"å³ã¯ãªãã¯"ã¯ä¸é¨ã®ã¢ããªã§ã¯å¹ããªã
- ä¸é¨ã®ã¢ããªã®ä¾ãã¿ã¹ã¯ããã¼ã¸ã£ã¼ããªã½ã¼ã¹ã¢ãã¿ã¼ã ã£ããããã®ã§ã¤ãã(å³ã¯ãªãã¯ãããä½ç½®ã§ãã¼ãã¼ãã®ã¡ãã¥ã¼ãã¼ãæ¼ãã¨ããæå·§ã§æä½ããäºã¯ã§ãã)
- ã«ã¹ã¿ãã¤ãºãè¨å®ããç»é¢ã§ã©ã®é ç®ãå®éã©ãã®ãã¿ã³ãªã®ãå³ãåºã¦ãã¦ããããã«ãã(çµæãé©å½ãªå²ãå½ã¦ããã¦ã©ã®ãã¿ã³ãå®éã«ã¯ã©ãã§â¦ã¨é½åº¦ç¢ºèªãã¦è¨å®ãã¦ãã¾ãã)
- ä¸å ·åå ±åæã®ãµãã¼ãã®å¯¾å¿ãæªãã£ã
rust ã® wasm ã¿ã¼ã²ããã®ããã¸ã§ã¯ã㧠surf-1.x ã surf-2.x ã¸å·®ãæ¿ããå ´åã«å¿ è¦ãªå¯¾å¿ã®ã¡ã¢
surf-1.x ç³»ã§ã¯âã®ããã« Cargo.toml ã«ãã¼ã¸ã§ã³çªå·ã¾ãã¯æå¨ã ãæ¸ãã° wasm åãã«ããã®ã¾ã¾ä½¿ãã¾ãããã¹ããã
# surf-1.x [dependencies] surf = "1.0.3"
surf-2.x ç³»ããâã®ããã« Cargo.toml ã« default-features
㨠features
ãæ示çã«è¨å®ããªã㨠wasm ã¿ã¼ã²ããã§ãã«ãã§ããªããªãã¾ããã
# surf-2.x surf = {version = "2.1.0", default-features = false, features = ["wasm-client"]}
ãã®è¨å®ãæ ãã¨âã®ãããªã¨ã©ã¼ã§ä¾å crates ã®ãã«ãä¸ã« surf ã®ãã«ããã¨ã©ã¼ã§å¤±æã«ãªãã¾ãã
Compiling surf v2.1.0 error[E0432]: unresolved import `http_client::isahc` --> C:\Users\usagi\.cargo\registry\src\github.com-1ecc6299db9ec823\surf-2.1.0\src\client.rs:12:26 | 12 | use http_client::isahc::IsahcClient as DefaultClient; | ^^^^^ could not find `isahc` in `http_client` error: aborting due to previous error For more information about this error, try `rustc --explain E0432`. error: could not compile `surf`.
surf-2.0 ã®ãªãªã¼ã¹ãã¼ãã«ããã¿ã㨠wasm åãã«ã¯ features ãæè¨å®ããªãã¨ãã¡ã«ãªããã£ã¦æ¸ãã¦ããï¼wasm-test/Cargo.tomlãåèã«ããã¨ãããã¾ããREADMEã§ã©ã©ã¼ãã¨WASMã§ä½¿ããããã°ãã®è¨å®ãã¦ãã¨ã¯æ¸ããã¦ããªãã®ã§å°ãä¸è¦ªåããããã¾ãããã®ã§ã¡ã¢ãæ®ãã¾ããã
`yarn licenses list --json` ã§ã¯ããã©ãæ°é ã®å ´åã« `npx license-checker --json` ããã¨å¬ããã¡ã¢ãã¨ãã¾ã㧠`Cargo.toml` 㧠rust ã®å ´åã®ã¡ã¢
package.json -> licenses.json
package.json 㨠npm|yarn ã使ã£ã¦ããããã¸ã§ã¯ãã§ãä¸è©±ã«ãªã£ã¦ããä¾åã©ã¤ãã©ãªã¼ã®ã©ã¤ã»ã³ã¹è¡¨ç¤ºãèªåçæãããæãã¨ãããã yarn
ã§
yarn licenses list --json
ããã¨ãâããã©ãããªJSONâãåºåãããäºãããã¾ãã
ãã®ã¨ãã®1581è¡ç®ã¯200,054æåããã¾ããã prettier ãéããªãããããã©ããã§ãã
ããã§ã
license-checker
https://www.npmjs.com/package/license-checker
ã«æ¿ãã¦ã¿ã¾ã:
npx license-checker --json --relativeLicensePath --summary
å¿ è¦ãªã¨ããã ãã®åºåã pretty ããã¦å¾ããã¾ããããã®åºåã ã¨ç®è¦ã«ããé¨åçãªç¢ºèªã楽ã§ãã©ã¤ã»ã³ã¹è¡¨ç¤ºã®èªåçæãããã¸ã§ã¯ãã®æ¹éãªã©ã§å¿ è¦ãªå ´åã«ã¯GPLã®æ··å ¥é²æ¢æ¤åºãªã©ãåé¡ãªãå¦çã§ãããã§ãã
ãã¾ã: Cargo.toml -> licenses.json
cargo-license
https://github.com/onur/cargo-license
cargo install cargo-license
ãã¦ããã¦ã
cargo-license -j
Rust ã® trait 㧠Option<Self> ã Result<Self, E> ã return ããé¢æ°ãå®ç¾©ãããã¨ã㦠[E0277] ã§æãããæã«æãåºãã¡ã¢
åé¡
// âããã¯åé¡ããã¾ãã trait Trait { fn function() -> Self; } // âãã㯠E0277: the size for values of type `Self` cannot be known at compilation time trait TraitOptional { fn function() -> Option<Self>; } // -> Result<Self, E> ã¨ãããå ´åãåæ§ã§ã(çç¥)
åé¿æ¹æ³
// Self ã®ä»£ããã«ã¸ã§ããªã¯ã¹ãåã¾ã㦠trait TraitOptional<T> { fn function() -> Option<T>; } struct Struct{} // impl ããã¨ãã«ã¸ã§ããªã¯ã¹ã®åå¼æ°ã« for ã¨åãåã渡ã impl TraitOptional<Struct> for Struct { fn function() -> Option<Self> { Some( Self{} ) } }
Rust ã®ã¡ã¢ãªã¼ã³ã³ããã¼çãªä½ããããããããæ´çãããã¼ãã·ã¼ãã®ã¡ã¢; T, Cell, RefCell, AtomicT, Mutex, RwLock, Rc, Arc
ä½ã£ãã®ã§ GitHub â ãã¤ã¤ããªãã¨ãªããããä¹ ãã¶ãã« Qiita ã«åå¿è ããã«åªããããªé°å²æ°ãè£ ã£ã解説â
ãæ¸ãã¦ã¿ã¾ãããã¡ãªã¿ã« reddit â
ã«ããã¹ããã¦ã¿ã¾ããã reddit ã¯ã¨ã¦ãåèã«ãªãè°è«ããããã建è¨çã«ãã®ãããå¢ãã§çºçãã¦ãããã®ã§å¬ããã§ãããã¼ãã·ã¼ãã¨ãã¦ã®æå³ã¨å³é¢ã®é½åã«ãã nitpick ãã¡ã¯ README ã«æ³¨éãä»ããã¨ããããªã¨æãã¾ããAllocationããã®ç·ã®è¦ç´ããªã© a better ãªã·ã¼ãã®ææ¡ã¯ãã¾ãåãè¾¼ãã§ãã§ããã ãã¦ã½ã®ç¡ããã§ããã¼ãã·ã¼ãã®æå³ã¨ãã¦ã¯ãããããããç¶æãã調æ´ããããã¨æãã¾ãã
ã¨ãããã ãæ¸ããã®ã§ã¯ããããããã°ã«ã¡ã¢ãæ®ãçç±ãèãã®ã§ãããã«ã¯ C++ 㨠Rust ã§ãã¼ãã·ã¼ãã«æ²è¼ããã¡ã¢ãªã¼ã³ã³ããã¼çãªããã®å¤§éæãªã³ã¼ããã翻訳ãéãã½ã¼ã¹ã¨ãã¦æ¸ãæ®ãã¦ã¿ã¾ãã
ãã¾ã: C++ ã® &âptr 㨠(mutable)/const ç³»ãRust ã® &âptr 㨠mut/const ç³»
// C++ #include <memory> #include <shared_mutex> #include <vector> #include <iostream> int main() { using T = int; using V = std::vector<T>; // mutable value T valm = 1; // const ref -> mutable value T& refc_valm = valm; refc_valm = 10; // const ref -> const value T const& refc_valc = valm; std::clog << refc_valc << " <- It's read only.\n"; // mutable ptr -> mutable value T* ptrm_valm = &valm; *ptrm_valm = 11; // const ptr -> mutable value T* const ptrc_valm = &valm; *ptrc_valm = 21; // const ptr -> const value const T* const ptrc_valc = &valm; std::clog << *ptrc_valc << " <- It's read only.\n"; // heap, â 'static lifetime of Rust T* ptrm_heap_static_lifetime = new int(-1); // heap, â mut Box<T> of Rust std::unique_ptr<T> ptrm_heap_single_owner_valm = std::make_unique<T>(-1); *ptrm_heap_single_owner_valm = -100; // heap, â Box<T> of Rust std::unique_ptr<const T> ptrm_heap_single_owner_valc = std::make_unique<T>(-1); // heap, â Rc<T> of Rust std::shared_ptr<const T> ptrm_heap_multiple_owner_thread_unsafe_valc = std::make_shared<T>(-1); // heap, â Rc<Cell<T>> of Rust std::shared_ptr<T> ptrm_heap_multiple_owner_thread_unsafe_valm = std::make_shared<T>(-1); // heap, â Rc<RefCell<V>> of Rust std::shared_ptr<V> ptrm_heap_multiple_owner_thread_unsafe_refm = std::make_shared<V>(V()); ptrm_heap_multiple_owner_thread_unsafe_refm->push_back(-2000); // single reader/writer control object, â Mutex<T> without <T> of Rust std::mutex mutex_1rw_thread_safe_controller; // multiple reader/single writer control object, â RwLock<T> without <T> of Rust std::shared_mutex mutex_mr1w_thread_safe_controller; }
// Rust; Rc:=Reference Counted, Arc:=Automatically Reference Counted use std:: { rc::Rc , sync::{Arc, Mutex, RwLock} , cell::{ Cell, RefCell } }; fn main() { type T = i32; type V = Vec<T>; // mutable value let mut valm: T = 1; let mut valm_the_other = 2; // const ref -> mutable value let refc_valm: &mut T = &mut valm; *refc_valm = 11; // const ptr -> const value let refc_valc: &T = &valm; println!("{} <-- It's a const value via const ref.", refc_valc); // mutable ptr -> mutable value; deref-ptr is an unsafe operation let mut ptrm_valm: *mut T = &mut valm as *mut T; unsafe { *ptrm_valm = 21 }; ptrm_valm = &mut valm_the_other as &mut T; unsafe { *ptrm_valm = 22 }; // const ptr -> mutable value let ptrc_valm: *mut T = &mut valm as *mut i32; unsafe { *ptrc_valm = 31 }; // const ptr -> const value let ptrc_valc: *const T = &valm as *const i32; println!("{:?} <-- It's a const value via const ptr.", ptrc_valc); // heap, â new of C++ let mut ptrm_heap_static_lifetime: *mut T = unsafe{ std::alloc::alloc( std::alloc::Layout::new::<T>() ) } as *mut T; unsafe { *ptrm_heap_static_lifetime = -10 }; // heap, â std::unique_ptr<T> of C++, deref -> mutable value let mut ptrm_heap_single_owner_valm: Box<T> = Box::<T>::new(-1); *ptrm_heap_single_owner_valm = -100; // heap, â std::unique_ptr<const T> of C++, deref -> mutable value let ptrm_heap_single_owner_valc: Box<T> = Box::<T>::new(-1); // heap, â std::shared_ptr<const T> of C++, deref -> const value let ptrm_heap_multiple_owner_thread_unsafe_valc: Rc<T> = Rc::<T>::new(-1); // heap, â std::shared_ptr<T> + std::mutex of C++, deref -> mutable value let ptrm_heap_multiple_owner_thread_unsafe_valm: Rc<Cell<T>> = Rc::new(Cell::<T>::new(-1)); ptrm_heap_multiple_owner_thread_unsafe_valm.set( -200 ); // heap, â std::shared_ptr<T> + std::mutex of C++, deref -> mutable ref let ptrm_heap_multiple_owner_thread_unsafe_refm: Rc<RefCell<V>> = Rc::new(RefCell::new(V::new())); ptrm_heap_multiple_owner_thread_unsafe_refm.borrow_mut().push( -2000 ); // heap, â std::shared_ptr<const T> of C++, deref -> const value let ptrm_heap_multiple_owner_thread_unsafe_valc: Arc<T> = Arc::<T>::new(-1); // heap, â std::shared_ptr<T> + std::shared_mutex of C++, deref -> mutable value let ptrm_heap_multiple_owner_thread_unsafe_valm: Arc<Mutex<T>> = Arc::new(Mutex::<T>::new(-1)); *ptrm_heap_multiple_owner_thread_unsafe_valm.lock().unwrap() = -200; // heap, â std::shared_ptr<T> + std::shared_mutex of C++, deref -> mutable ref let ptrm_heap_multiple_owner_thread_unsafe_refm: Arc<RwLock<T>> = Arc::new(RwLock::<T>::new(-1)); { let r0 = *ptrm_heap_multiple_owner_thread_unsafe_refm.read().unwrap(); let r1 = *ptrm_heap_multiple_owner_thread_unsafe_refm.read().unwrap(); println!("r0 = {:?}, r1 = {:?}", r0, r1); // drop(ârelease) r0, r1 then it will be writable in the out of this scope } *ptrm_heap_multiple_owner_thread_unsafe_refm.write().unwrap() = -3000; }
åè
- rust — Rustのセルと参照カウントタイプについての全体的な説明が必要
- Unsafe Rust - The Rust Programming Language
- RefCell<T>と内部可変性パターン - The Rust Programming Language
- Arc<Mutex<T>>という形はデザインパターン - Rustコトハジメ
- brughdiggity comments on Hey Rustaceans! Got an easy question? Ask here (22/2017)!
- Explicate what "Rc" and "Arc" stand for. by ucarion · Pull Request #42419 · rust-lang/rust · GitHub
- Rust RefCell(T) - javatpoint
- Rust book 勉強会 #7 - slideship.com
Rust ã§å®è¡ä¸ã«ãããã¡ã¼ã®æ¬¡å 解éãå¤æ´ã§ãã DimensionShiftableBuffer ã¨ç¿»è¨³æã«ä»»æã®æ¬¡å 解éãVec<T>ã«è¿½å ãã vec-dimension-shift ãå ¬éãã¾ãããã®ã¡ã¢
- dimension_shift_buffer
- vec-dimension-shift
åæã¨ãã¦ãã©ã¡ããåä¸ã®ãã¼ãã«å ¨ä½ãé£ç¶ããã¡ã¢ãªã¼ã¢ãã¬ã¹ãæã¤ãããã¡ã¼ãæ±ããã¨ããäºãããã¾ãããã®ããã§ããããã¡ã¼ãä»»æ次å ã«å解éãã¾ãã
dimension_shiftable_buffer
å®è¡æã«ä»»æã®æ¬¡å
ã«ãããã¡ã¼ã®è§£éãå¤æ´ãããã¥ã¼ãç¨ãã¦ãããã¡ã¼ãæ±ããããããããã®ã§ãããã¡ãã®å®è£
ã¯ãã¹ã¦ Safe ã§ãã unsafe
ããã« Vec<T>
ãå®è¡æã«ä»»æ次å
ã¸å解éããæ¹æ³ã¯æãã¤ããªãã£ãã®ã§ getter(get,pop,remove)/setter(push,append) 㨠for_each
ãç¨æãã¾ããããã¡ãã®å©ç¹ã¯ãå®è¡æã«ããä»»æ次å
ã¸ãã§ãã
// make a 2d-empty DimensionShiftableBuffer let mut dsb = DimensionShiftableBuffer::<u8>::new(vec![], 2).unwrap(); // push a 2d-datum dsb.push(&[0u8, 1]).unwrap(); // push a 2d-datum dsb.push(&[2u8, 3]).unwrap(); // append a 2d-datum sequence dsb.append(&[4u8, 5, 6, 7, 8, 9, 10, 11]).unwrap(); for index in 0..dsb.len().unwrap() { // get a 2d slice assert_eq!(dsb.get(index).unwrap(), &[index as u8 * 2, index as u8 * 2 + 1]); } // shift dimension to 3 from 2 dsb.shift_dimension(3).unwrap(); // push a 3d-datum dsb.push(&[12u8, 13, 14]).unwrap(); // get a 3d-datum assert_eq!(dsb.get(0).unwrap(), &[0u8, 1, 2]); assert_eq!(dsb.get(1).unwrap(), &[3u8, 4, 5]); assert_eq!(dsb.get(2).unwrap(), &[6u8, 7, 8]); assert_eq!(dsb.get(3).unwrap(), &[9u8, 10, 11]); assert_eq!(dsb.get(4).unwrap(), &[12u8, 13, 14]); // get a linear slice let linear_slice = dsb.as_slice(); assert_eq!(linear_slice, &[0u8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]);
vec-dimension-shift
ãã¡ãã¯ç¿»è¨³æã«N次å
ããå®éã«å¯¾å¿ããå
·ä½çãªæ¬¡å
ã®æ¬¡å
å解éæ©è½ãé¸æçã« Vec<T>
ã¸ä»ä¸ãã trait
éã§ãã usize
次å
ã®ãã¹ã¦ã®ãã¿ã¼ã³ã lib ã«åãå°½ããããã«ã¯ãããªãã®ã§ã2..16次å
㯠features ã§é¸æçã«ä½¿ç¨å¯è½ã«ã default 㧠2,3,4 次å
ã® trait
s ãå®ç¾©ã¨ãã¤ã¤ã make_vec_dimension_shift_n_dimension!
ãã¯ããã¦ã¼ã¶ã¼ãä»»æã«å¼ã¹ãããã« pub ãã crate ã®ã¦ã¼ã¶ã¼ãä»»æã«æ¬²ãã次å
ãé¸æçã«æ±ããããã«ãã¦ãã¾ãã
ãã£ã¡ã®ä¸èº«ã¯é»éè¡ã¨ unsafe
ã§ã§ãã¦ãã¾ãã次å
å解éæã®å¢çãã§ãã¯ãç´æ¥ã®å¤æãä¸å¯è½ãªå ´åã®Err
|truncate|paddingãªã©åºæ¬çã«ã¯å®å
¨ã«ä½¿ããããããã«å®è£
ãã¦ãã¾ãããN次å
ãã1次å
åããããã® flatten ã®å®è£
ã§ã¯ Vec
ã®å®è£
ã¨ã¡ã¢ãªã¼ã¬ã¤ã¢ã¦ããã«ãã¼ãããããã¦ããããã¾ãã
use vec_dimension_shift::{ VecDimensionShift2D, VecDimensionShift2DFlatten, VecDimensionShift3D, VecDimensionShift3DFlatten }; fn d2_and_d3() { let original = vec![0.0, 1.1, 2.2, 3.3, 4.4, 5.5]; dbg!(&original); let mut d2_shifted = original.as_2d_array().unwrap(); dbg!(&d2_shifted); assert_eq!(d2_shifted[0], [0.0, 1.1]); assert_eq!(d2_shifted[1], [2.2, 3.3]); assert_eq!(d2_shifted[2], [4.4, 5.5]); d2_shifted[1][1] = -1.0; let flatten = d2_shifted.as_flatten(); dbg!(&flatten); let mut d3_shifted = flatten.as_3d_array().unwrap(); dbg!(&d3_shifted); assert_eq!(d3_shifted[0], [0.0, 1.1, 2.2]); assert_eq!(d3_shifted[1], [-1.0, 4.4, 5.5]); d3_shifted[1][1] = -2.0; let flatten = d3_shifted.as_flatten(); dbg!(&flatten); assert_eq!(flatten, vec![0.0, 1.1, 2.2, -1.0, -2.0, 5.5]) }
ã¡ãªã¿ã«ã 1D -> 2D ã¨ããå¾ã« 1D 㸠flattening ããã 1D -> 2D -> 3D ã¨æ¬¡å å解éããã¨ã
use vec_dimension_shift::make_vec_dimension_shift_n_dimension; fn n_dimension_macro_generator() { make_vec_dimension_shift_n_dimension! { VecDimensionShift2D, VecDimensionShift2DFlatten, as_2d_array_no_check, to_2d_array_no_check, as_2d_array, to_2d_array, as_2d_array_truncate, to_2d_array_truncate, as_2d_array_padding, to_2d_array_padding, 2 } make_vec_dimension_shift_n_dimension! { VecDimensionShift3D, VecDimensionShift3DFlatten, as_3d_array_no_check, to_3d_array_no_check, as_3d_array, to_3d_array, as_3d_array_truncate, to_3d_array_truncate, as_3d_array_padding, to_3d_array_padding, 3 } let original = vec![0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.10, 11.11]; dbg!(&original); let d2 = original.as_2d_array().unwrap(); assert_eq!(d2[0], [0.0, 1.1]); assert_eq!(d2[1], [2.2, 3.3]); assert_eq!(d2[2], [4.4, 5.5]); assert_eq!(d2[3], [6.6, 7.7]); assert_eq!(d2[4], [8.8, 9.9]); assert_eq!(d2[5], [10.10, 11.11]); dbg!(&d2); let d3 = d2.as_3d_array().unwrap(); assert_eq!(d3[0], [[0.0, 1.1], [2.2, 3.3], [4.4, 5.5]]); assert_eq!(d3[1], [[6.6, 7.7], [8.8, 9.9], [10.10, 11.11]]); dbg!(&d3); }
ããããå¤N次å (N次å ÃN次å Ãâ¦)ãä½ãã¾ãã