Skip to content

Commit bdde4f7

Browse files
committed
Fix dyn trait
1 parent 74978a0 commit bdde4f7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/decision_tree.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ impl DecisionTree {
17461746
/// let node: Value = serde_json::from_str(data).unwrap();
17471747
/// let dt = DecisionTree::get_from_xgboost(&node);
17481748
/// ```
1749-
pub fn get_from_xgboost(node: &serde_json::Value) -> Result<Self, Box<Error>> {
1749+
pub fn get_from_xgboost(node: &serde_json::Value) -> Result<Self, Box<dyn Error>> {
17501750
// Parameters are not used in prediction process, so we use default parameters.
17511751
let mut tree = DecisionTree::new();
17521752
let index = tree.tree.add_root(BinaryTreeNode::new(DTNode::new()));
@@ -1759,7 +1759,7 @@ impl DecisionTree {
17591759
&mut self,
17601760
index: TreeIndex,
17611761
node: &serde_json::Value,
1762-
) -> Result<(), Box<Error>> {
1762+
) -> Result<(), Box<dyn Error>> {
17631763
{
17641764
let node_ref = self
17651765
.tree
@@ -1798,7 +1798,7 @@ impl DecisionTree {
17981798
} else if missing == right_child {
17991799
node_ref.value.missing = 1;
18001800
} else {
1801-
let err: Box<Error> = From::from("not support extra missing node".to_string());
1801+
let err: Box<dyn Error> = From::from("not support extra missing node".to_string());
18021802
return Err(err);
18031803
}
18041804
}
@@ -1835,7 +1835,7 @@ impl DecisionTree {
18351835
}
18361836

18371837
if (!find_left) || (!find_right) {
1838-
let err: Box<Error> = From::from("children not found".to_string());
1838+
let err: Box<dyn Error> = From::from("children not found".to_string());
18391839
return Err(err);
18401840
}
18411841
Ok(())

src/gradient_boost.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ impl GBDT {
707707
/// // Save model.
708708
/// // gbdt.save_model("gbdt.model");
709709
/// ```
710-
pub fn save_model(&self, filename: &str) -> Result<(), Box<Error>> {
710+
pub fn save_model(&self, filename: &str) -> Result<(), Box<dyn Error>> {
711711
let mut file = File::create(filename)?;
712712
let serialized = serde_json::to_string(self)?;
713713
file.write_all(serialized.as_bytes())?;
@@ -726,7 +726,7 @@ impl GBDT {
726726
///
727727
/// # Error
728728
/// Error when get exception during model file parsing or deserialize.
729-
pub fn load_model(filename: &str) -> Result<Self, Box<Error>> {
729+
pub fn load_model(filename: &str) -> Result<Self, Box<dyn Error>> {
730730
let mut file = File::open(filename)?;
731731
let mut contents = String::new();
732732
file.read_to_string(&mut contents)?;
@@ -746,7 +746,7 @@ impl GBDT {
746746
///
747747
/// # Error
748748
/// Error when get exception during model file parsing.
749-
pub fn from_xgoost_dump(model_file: &str, objective: &str) -> Result<Self, Box<Error>> {
749+
pub fn from_xgoost_dump(model_file: &str, objective: &str) -> Result<Self, Box<dyn Error>> {
750750
let tree_file = File::open(&model_file)?;
751751
let reader = BufReader::new(tree_file);
752752
let mut all_lines: Vec<String> = Vec::new();

src/input.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn infer(file_name: &str) -> InputFormat {
286286
///
287287
/// # Error
288288
/// Raise error if file cannot be read correctly.
289-
pub fn load_csv(file: &mut File, input_format: InputFormat) -> Result<DataVec, Box<Error>> {
289+
pub fn load_csv(file: &mut File, input_format: InputFormat) -> Result<DataVec, Box<dyn Error>> {
290290
file.seek(SeekFrom::Start(0))?;
291291
let mut dv = Vec::new();
292292

@@ -337,7 +337,7 @@ pub fn load_csv(file: &mut File, input_format: InputFormat) -> Result<DataVec, B
337337
///
338338
/// # Error
339339
/// Raise error if file cannot be read correctly.
340-
pub fn load_txt(file: &mut File, input_format: InputFormat) -> Result<DataVec, Box<Error>> {
340+
pub fn load_txt(file: &mut File, input_format: InputFormat) -> Result<DataVec, Box<dyn Error>> {
341341
file.seek(SeekFrom::Start(0))?;
342342
let mut dv = Vec::new();
343343

@@ -414,7 +414,7 @@ pub fn load_txt(file: &mut File, input_format: InputFormat) -> Result<DataVec, B
414414
///
415415
/// # Error
416416
/// Raise error if file cannot be open correctly.
417-
pub fn load(file_name: &str, input_format: InputFormat) -> Result<DataVec, Box<Error>> {
417+
pub fn load(file_name: &str, input_format: InputFormat) -> Result<DataVec, Box<dyn Error>> {
418418
let mut file = File::open(file_name.to_string())?;
419419
match input_format.ftype {
420420
FileFormat::CSV => load_csv(&mut file, input_format),

0 commit comments

Comments
 (0)