Skip to content

Commit 918a9ba

Browse files
Merge branch '36-fix-code-scanning-alert---usage-of-a-legacy-numeric-constant' into main
2 parents 3f8ec42 + 8418638 commit 918a9ba

File tree

6 files changed

+45
-30
lines changed

6 files changed

+45
-30
lines changed

Cargo.lock

Lines changed: 24 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/aadhaar.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::fmt::Display;
22
use std::ops::Deref;
33
use std::ptr;
4-
use std::u8::MAX;
54

65
use super::aadesh::Aadesh;
76
use super::dosa_nirupaka;
@@ -33,9 +32,15 @@ pub struct Aadhaar {
3332
prarambhkarta_string: GcRef<Vakya>,
3433
}
3534

35+
impl Default for Aadhaar {
36+
fn default() -> Self {
37+
Self::new()
38+
}
39+
}
40+
3641
impl Aadhaar {
3742
const ADHIKTAM_KOSHA: usize = 64;
38-
const ADHIKTAM_RASHI: usize = Aadhaar::ADHIKTAM_KOSHA * (MAX as usize) + 1;
43+
const ADHIKTAM_RASHI: usize = Aadhaar::ADHIKTAM_KOSHA * (u8::MAX as usize) + 1;
3944

4045
pub fn new() -> Self {
4146
let mut gc = Gc::new();
@@ -614,7 +619,7 @@ impl Aadhaar {
614619
}
615620
paddhati_name => {
616621
return self.anusthanakale_dosa(
617-
format!("{} सूचिस्य पद्धतिरन्यत् न भवति", paddhati_name).as_str(), //is not a paddhati of list
622+
format!("{paddhati_name} सूचिस्य पद्धतिरन्यत् न भवति").as_str(), //is not a paddhati of list
618623
);
619624
}
620625
}

core/src/dosa_nirupaka.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ pub struct Disassembler<'vm> {
1010
impl<'vm> Disassembler<'vm> {
1111
fn const_aadesh(&self, op: &str, achar_anukram: u8) {
1212
let mulya = self.vastu.achar[achar_anukram as usize];
13-
println!("{:<16} {:4} ({})", op, achar_anukram, mulya);
13+
println!("{op:<16} {achar_anukram:4} ({mulya})");
1414
}
1515

1616
fn const_list_aadesh(&self, op: &str, achar_anukram: u16) {
1717
let mulya = self.vastu.achar[achar_anukram as usize];
18-
println!("{:<16} {:4} ({})", op, achar_anukram, mulya);
18+
println!("{op:<16} {achar_anukram:4} ({mulya})");
1919
}
2020

2121
pub fn disassemble(&self, name: &str) {
22-
println!("== BEGIN {} ==", name);
22+
println!("== BEGIN {name} ==");
2323
for (offset, op) in self.vastu.code.iter().enumerate() {
2424
self.op(op, offset);
2525
}
26-
println!("== END {} ==", name);
26+
println!("== END {name} ==");
2727
println!();
2828
}
2929

3030
fn invoke_aadesh(&self, op: &str, achar_anukram: u8, args: u8) {
3131
let mulya = self.vastu.achar[achar_anukram as usize];
32-
println!("{:<16} {:4} ({}) {}", op, achar_anukram, mulya, args);
32+
println!("{op:<16} {achar_anukram:4} ({mulya}) {args}");
3333
}
3434

3535
fn jump_aadesh(&self, op: &str, offset: u16) {
36-
println!("{:<16} {:4}", op, offset);
36+
println!("{op:<16} {offset:4}");
3737
}
3838

3939
pub fn new(vastu: &'vm Vastu, rashi: Option<&'vm [Mulya]>) -> Self {
@@ -42,12 +42,12 @@ impl<'vm> Disassembler<'vm> {
4242

4343
pub fn op(&self, op: &Aadesh, offset: usize) {
4444
self.rashi();
45-
print!("{:04} ", offset);
45+
print!("{offset:04} ");
4646
let line = &self.vastu.sthaan[offset];
4747
if offset > 0 && line == &self.vastu.sthaan[offset - 1] {
4848
print!(" | ");
4949
} else {
50-
print!("{:>4} ", line);
50+
print!("{line:>4} ");
5151
}
5252
match op {
5353
Aadesh::Vidhi(c) => self.const_aadesh("Vidhi", *c),
@@ -98,14 +98,14 @@ impl<'vm> Disassembler<'vm> {
9898
}
9999

100100
fn slot_aadesh(&self, op: &str, slot: u8) {
101-
println!("{:<16} {:4}", op, slot);
101+
println!("{op:<16} {slot:4}");
102102
}
103103

104104
fn rashi(&self) {
105105
if let Some(rashi) = self.rashi {
106106
println!(" S: ");
107107
for &mulya in rashi.iter() {
108-
println!("\t[{}]", mulya);
108+
println!("\t[{mulya}]");
109109
}
110110
println!();
111111
}

core/src/fetchsource.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct Sourcecode<'sc> {
99
}
1010

1111
impl<'sc> Sourcecode<'sc> {
12-
pub fn new(filepath: &'sc str) -> Result<Sourcecode> {
12+
pub fn new(filepath: &'sc str) -> Result<Sourcecode<'sc>> {
1313
// let abs_path = fs::canonicalize(filepath)?;
1414
let path = Path::new(filepath);
1515
let code = fs::read_to_string(path)?;

core/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ impl<'p> Parser<'p> {
680680
self.expression();
681681
self.emit(Aadesh::SetItem);
682682
} else {
683-
self.dosa("अमान्यं नियोजन लक्ष्यम्"); // Invalid niyojana target
683+
self.dosa("अमान्यं नियोजन\u{200B} लक्ष्यम्"); // Invalid niyojana target
684684
}
685685
}
686686
}

core/src/smrti.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl Iterator for IterSmrti {
259259
type Item = (GcRef<Vakya>, Mulya);
260260

261261
fn next(&mut self) -> Option<Self::Item> {
262-
while self.ptr as *const Pravisti != self.end {
262+
while !std::ptr::eq(self.ptr, self.end) {
263263
unsafe {
264264
let pravisti = self.ptr;
265265
self.ptr = self.ptr.offset(1);

0 commit comments

Comments
 (0)