Fix errors and inconcistency with this requirement in the part of the minimal viable solution of the problems, written in rust code, using only std and libraries that is explicitly used in code below, pointing in which files which update needed and which new files need to create with which code. Task: define in …/project/src/datacode.rs a Global Struct and a Generic, that can be read and updated by any function or macro in …/project/src/main.rs or …/project/src/subproject/src/lib.rs, intended for filling data from a bunch of files. Above data strutures are initializing with the same set of rows, taken from files, which rows consisting of 3 cells type of &str. Although I explicitly mentioning the type of the cells in this task as &str, this is just for example, so design each data structs so it can deal with any type of data not limiting to string cells or example ones. Again, just for example, use hashmap (use 1st &str as a key, two rest as values), hashset (all three cells goes into hashset as \t tab-separated in one string), vec (use 1st &str as a key, rest as values), and another entity BinaryHeap in similar fashion. There are errors in the …/project/src/datacode.rs part: 


use std::collections::{BTreeMap, HashMap, HashSet};
use std::cmp::{Ord, Reverse};
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::vec::Vec;

#[derive(Debug)]
pub struct MyGlobalStruct<T> {
hashmap: HashMap<String, (T, T, T)>,
hashset: HashSet<String>,
vec: Vec<(String, (T, T, T))>,
binary_heap: BinaryHeap<(T, String, T)>,
// add other fields as needed
}

#[derive(Debug)]
pub struct BinaryHeap<T> {
heap: Vec<T>,
}

impl<T: Ord> BinaryHeap<T> {
pub fn new() -> Self {
BinaryHeap { heap: Vec::new() }
}

pub fn push(&mut self, x: T) {
self.heap.push(x);
self.heap.sort_by_key(|k| Reverse(k));
}

pub fn pop(&mut self) -> Option<T> {
self.heap.pop()
}
}

impl<T: Clone> MyGlobalStruct<T> {
pub fn new() -> MyGlobalStruct<T> {
MyGlobalStruct {
hashmap: HashMap::new(),
hashset: HashSet::new(),
vec: Vec::new(),
binary_heap: BinaryHeap::new(),
// initialize other fields as needed
}
}

pub fn from_files(file_paths: &[&str]) -> io::Result<MyGlobalStruct<T>> {
let mut data = MyGlobalStruct::new();

for file_path in file_paths {
let file = File::open(file_path)?;
let reader = BufReader::new(file);

for line in reader.lines() {
if let Ok(data_row) = line {
let row = data_row.split('\t').collect::<Vec<&str>>();

if row.len() == 3 {
let (key, value1, value2) = (row[0], row[1], row[2]);
data
.hashmap
.insert(key.to_string(), (value1.to_string(), value2.to_string(), "".to_string()));
data.hashset.insert(data_row);
data.vec.push((key.to_string(), (value1.to_string(), value2.to_string(), "".to_string())));
data.binary_heap.push((value1.to_string(), key.to_string(), value2.to_string()));
}
}
}
}

Ok(data)
}

// add other methods as needed
}

/*
error: src/datacode.rs:42: the trait bound `T: Ord` is not satisfied
error: src/datacode.rs:42: the trait `Ord` is not implemented for `T`

error: src/datacode.rs:71: mismatched types
error: src/datacode.rs:71: expected type parameter `T`, found struct `String`
error: src/datacode.rs:71: arguments to this enum variant are incorrect

error: src/datacode.rs:36: this type parameter
*/