Skip to content

Commit

Permalink
fixed : accessing first element with .first() insted of args.get(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
PtPrashantTripathi authored Jun 14, 2024
1 parent 34206b3 commit cbe58db
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/moolsutra/std_ank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::super::mulya::Mulya;
/// this function converts a string to a number
pub fn ank(aadhaar: &mut Aadhaar, from: usize) -> Result<Mulya, Dosa> {
let args = &aadhaar.rashi[from..aadhaar.rashi_len()];
let arg = args.get(0);
let arg = args.first();
if let Some(arg) = arg {
let mut num = String::new();
let digit_mapping = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'];
Expand Down
2 changes: 1 addition & 1 deletion core/src/moolsutra/std_kul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::super::mulya::Mulya;
/// this function returns the length of the given string
pub fn kul(aadhaar: &mut Aadhaar, from: usize) -> Result<Mulya, Dosa> {
let args = &aadhaar.rashi[from..aadhaar.rashi_len()];
let arg = args.get(0);
let arg = args.first();
if let Some(val) = arg {
match val {
Mulya::Vakya(string) => Ok(Mulya::Ank(string.s.len() as f64)),
Expand Down
2 changes: 1 addition & 1 deletion core/src/moolsutra/std_nirgam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::super::mulya::Mulya;
/// this function exits the program with the given exit code
pub fn nirgam(aadhaar: &mut Aadhaar, from: usize) -> Result<Mulya, Dosa> {
let args = &aadhaar.rashi[from..aadhaar.rashi_len()];
let code = match args.get(0) {
let code = match args.first() {
Some(Mulya::Ank(code)) => *code as i32,
_ => 0,
};
Expand Down
2 changes: 1 addition & 1 deletion core/src/moolsutra/std_prakaar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::super::mulya::Mulya;
pub fn prakaar(aadhaar: &mut Aadhaar, from: usize) -> Result<Mulya, Dosa> {
let args = &aadhaar.rashi[from..aadhaar.rashi_len()];

if let Some(arg) = args.get(0) {
if let Some(arg) = args.first() {
match arg {
Mulya::Vakya(_v) => Ok(Mulya::Vakya(aadhaar.gc.intern("वाक्य".to_owned()))),
Mulya::Ank(_v) => Ok(Mulya::Vakya(aadhaar.gc.intern("अंक".to_owned()))),
Expand Down
2 changes: 1 addition & 1 deletion core/src/moolsutra/std_shabd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::super::mulya::Mulya;
/// this function returns the given string
pub fn shabd(aadhaar: &mut Aadhaar, from: usize) -> Result<Mulya, Dosa> {
let args = &aadhaar.rashi[from..aadhaar.rashi_len()];
let arg = args.get(0);
let arg = args.first();
if let Some(arg) = arg {
Ok(Mulya::Vakya(aadhaar.gc.intern(arg.to_string())))
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/src/moolsutra/std_truti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::super::mulya::Mulya;
/// this function throws an dosa with the given string
pub fn truti(aadhaar: &mut Aadhaar, from: usize) -> Result<Mulya, Dosa> {
let args = &aadhaar.rashi[from..aadhaar.rashi_len()];
if let Some(arg) = args.get(0) {
if let Some(arg) = args.first() {
let dosa = format!("त्रुटि : {arg}");
Err(aadhaar.throw_dosa(&dosa))
} else {
Expand Down

0 comments on commit cbe58db

Please sign in to comment.