(&mut self, func_name: &str, nodes: &[GraphNode])
| 262 | |
| 263 | impl Graph { |
| 264 | fn check_deps_are_valid(&mut self, func_name: &str, nodes: &[GraphNode]) -> CudaResult<()> { |
| 265 | // per the docs, nodes must be valid AND not duplicate. |
| 266 | for (idx, node) in nodes.iter().enumerate() { |
| 267 | if let Some(pos) = nodes |
| 268 | .iter() |
| 269 | .enumerate() |
| 270 | .position(|(cur_idx, x)| x == node && cur_idx != idx) |
| 271 | { |
| 272 | panic!("Duplicate dependency found in call to `{}`, the first instance is at index {}, the second instance is at index {}", func_name, idx, pos); |
| 273 | } |
| 274 | |
| 275 | assert!( |
| 276 | self.is_valid_node(*node)?, |
| 277 | "Invalid (dropped or from another graph) node was given to `{}`", |
| 278 | func_name |
| 279 | ); |
| 280 | } |
| 281 | Ok(()) |
| 282 | } |
| 283 | |
| 284 | /// Check if a node is valid in this graph. |
| 285 | pub fn is_valid_node(&mut self, node: GraphNode) -> CudaResult<bool> { |
no test coverage detected