Rust Constants
Constants คือค่าคงที่ที่กำหนดไว้ใน standard library ใช้งานได้ทันทีโดยไม่ต้องคำนวณ
Constants คืออะไร
Section titled “Constants คืออะไร”Rust std มี constants หลายประเภท:
- Numeric constants: PI, E, MAX, MIN
- Platform constants: ARCH, OS
- Special values: INFINITY, NAN
use std::f64::consts::*;
fn main() { println!("PI = {}", PI); println!("E = {}", E); println!("i32::MAX = {}", i32::MAX); println!("OS = {}", std::env::consts::OS);}เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google