Don't rely on the order of elements returned by `rustc_compile_action`

We now depend on providers' attributes, which is unfortunate, however that's the best we can do as long as `rustc_compile_action` returns a list.

PiperOrigin-RevId: 446162811
diff --git a/rs_bindings_from_cc/bazel_support/rust_bindings_from_cc_utils.bzl b/rs_bindings_from_cc/bazel_support/rust_bindings_from_cc_utils.bzl
index a8aa9ff..a88d5e5 100644
--- a/rs_bindings_from_cc/bazel_support/rust_bindings_from_cc_utils.bzl
+++ b/rs_bindings_from_cc/bazel_support/rust_bindings_from_cc_utils.bzl
@@ -91,6 +91,18 @@
         linking_context = linking_context,
     )
 
+def _get_crate_info(providers):
+    for provider in providers:
+        if hasattr(provider, "name"):
+            return provider
+    fail("Couldn't find a CrateInfo in the list of providers")
+
+def _get_dep_info(providers):
+    for provider in providers:
+        if hasattr(provider, "direct_crates"):
+            return provider
+    fail("Couldn't find a DepInfo in the list of providers")
+
 def _compile_rust(ctx, attr, src, deps):
     """Compiles a Rust source file.
 
@@ -142,8 +154,8 @@
     )
 
     return DepVariantInfo(
-        crate_info = providers[0],
-        dep_info = providers[1],
+        crate_info = _get_crate_info(providers),
+        dep_info = _get_dep_info(providers),
         cc_info = None,
         build_info = None,
     )