Hello all,
I hate to keep bothering everyone with my trivial questions. Two steps forward and one step back. I am trying to place a value, a string, into a vector field of a structure. I get this compiler error.
```error[E0599]: no method named push_str
found for struct std::vec::Vec<Team>
in the current scope
--> src/main.rs:73:19
|
73 | baseball.team.push_str( String::from("Rockies") );
| ^^^^^^^^ method not found in std::vec::Vec<Team>
error: aborting due to previous error
For more information about this error, try rustc --explain E0599
.
error: could not compile struct-test
.```
my code is:
structure declarations
*/
#[derive(Debug)]
struct Baseball {
team: Vec<Team>,
}
#[derive(Debug)]
struct Team {
name: String,
mascot: String,
coach: Coach,
}
#[derive(Debug)]
struct Coach {
name: String,
experience_years: u32,
years_hd_coach: u32,
win_lose: (u32,u32),
asst_coaches: Vec<AsstCoach>,
}
#[derive(Debug)]
struct AsstCoach {
name: String,
coach_of: String,
experience_years: u32,
players: Vec<Players>,
}
#[derive(Debug)]
struct Players {
name: String,
position: String,
experience_years: u32,
errors_game: u32,
batting_avg: u32,
}
/*
start of main
*/
fn main() {
let mut players = Players {
name: String::new(),
position: String::new(),
experience_years: 0,
errors_game: 0,
batting_avg: 0,
};
let mut asstcoach = AsstCoach {
name: String::new(),
coach_of: String::new(),
experience_years: 0,
players: vec![players],
};
let mut coach = Coach {
name: String::new(),
experience_years: 0,
years_hd_coach: 0,
win_lose: (0,0),
asst_coaches: vec![asstcoach],
};
let mut team = Team {
name: String::new(),
mascot: String::new(),
coach,
};
let mut baseball = Baseball {
team: vec![team],
};
println!("content of structures: {:#?}", baseball);
baseball.team.push_str( String::from("Rockies") );
}
thank you all for your help
rustuser99