Skip to content

Commit b02dcbd

Browse files
committed
docs: Avoid using get(0) in examples
I used this example to implement tests, but clippy is not much happy about that so changing also the docs to avoid leading by bad example next fellow readers: error: accessing first element with `attrs.get(0)` --> cryptoki/tests/basic.rs:2528:26 | 2528 | assert!(matches!(attrs.get(0), Some(Attribute::UniqueId(_)))); | ^^^^^^^^^^^^ help: try: `attrs.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first Signed-off-by: Jakub Jelen <[email protected]>
1 parent c7642c8 commit b02dcbd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cryptoki/src/session/object_management.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const MAX_OBJECT_COUNT: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(10)
5757
///
5858
/// let attributes = session.get_attributes(obj, &wanted_attr)?;
5959
///
60-
/// match attributes.get(0) {
60+
/// match attributes.first() {
6161
/// Some(Attribute::Label(l)) => {
6262
/// println!(
6363
/// "token object #{}: handle {}, label {}",
@@ -413,7 +413,7 @@ impl Session {
413413
/// session.login(UserType::User, Some(&AuthPin::new("fedcba".into())));
414414
///
415415
/// let empty_attrib= vec![];
416-
/// if let Some(object) = session.find_objects(&empty_attrib).unwrap().get(0) {
416+
/// if let Some(object) = session.find_objects(&empty_attrib).unwrap().first() {
417417
/// let attribute_types = vec![
418418
/// AttributeType::Token,
419419
/// AttributeType::Private,

0 commit comments

Comments
 (0)