Clean up a couple weird plurals

This commit is contained in:
asonix 2020-08-09 17:46:57 -05:00
parent 8e81b9edb2
commit d34df729bc
4 changed files with 25 additions and 21 deletions

View file

@ -1,4 +1,8 @@
# Unreleased
- Rename plural methods
- src/actor.rs set_streams -> set_stream, add_streams -> add_stream
- src/collections.rs set_items -> set_item, add_items -> add_item
- src/object.rs set_replies -> set_reply, add_replies -> add_reply
# 0.7.0-alpha.3
- Add `.into_parts()` for some types where it makes sense

View file

@ -581,7 +581,7 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
/// # let mut person = ApActor::new(context(), Person::new());
/// use activitystreams::prelude::*;
///
/// person.set_streams(uri!("https://example.com/liked"));
/// person.set_stream(uri!("https://example.com/liked"));
/// # Ok(())
/// # }
/// ```
@ -632,7 +632,7 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
/// # fn main() -> Result<(), anyhow::Error> {
/// # use activitystreams::{actor::{ApActor, Person}, context};
/// # let mut person = ApActor::new(context(), Person::new());
/// # person.set_id(context()).add_streams(context()).add_streams(context());
/// # person.set_id(context()).add_stream(context()).add_stream(context());
/// use activitystreams::prelude::*;
///
/// if let Some(streams) = person.streams()? {
@ -719,11 +719,11 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
/// # let mut person = ApActor::new(context(), Person::new());
/// use activitystreams::prelude::*;
///
/// person.set_streams(uri!("https://example.com/streams"));
/// person.set_stream(uri!("https://example.com/streams"));
/// # Ok(())
/// # }
/// ```
fn set_streams(&mut self, streams: Url) -> &mut Self {
fn set_stream(&mut self, streams: Url) -> &mut Self {
self.ap_actor_mut().streams = Some(streams.into());
self
}
@ -762,12 +762,12 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
/// use activitystreams::prelude::*;
///
/// person
/// .add_streams(uri!("https://example.com/streams1"))
/// .add_streams(uri!("https://example.com/streams2"));
/// .add_stream(uri!("https://example.com/streams1"))
/// .add_stream(uri!("https://example.com/streams2"));
/// # Ok(())
/// # }
/// ```
fn add_streams(&mut self, stream: Url) -> &mut Self {
fn add_stream(&mut self, stream: Url) -> &mut Self {
let v = match self.ap_actor_mut().streams.take() {
Some(mut v) => {
v.add(stream);
@ -800,7 +800,7 @@ pub trait ApActorExt<Inner>: AsApActor<Inner> {
/// # fn main() -> Result<(), anyhow::Error> {
/// # use activitystreams::{actor::{ApActor, Person}, context, uri};
/// # let mut person = ApActor::new(context(), Person::new());
/// # person.set_streams(uri!("https://example.com/streams"));
/// # person.set_stream(uri!("https://example.com/streams"));
/// use activitystreams::prelude::*;
///
/// assert!(person.streams_unchecked().is_some());

View file

@ -12,7 +12,7 @@
//! let mut collection = OrderedCollection::new();
//!
//! collection
//! .set_items(uri!("https://example.com/notes/1234"))
//! .set_item(uri!("https://example.com/notes/1234"))
//! .set_total_items(1u64)
//! .set_current(uri!("https://example.com/notes/1234"))
//! .set_first(uri!("https://example.com/notes/1234"))
@ -107,11 +107,11 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
/// # use activitystreams::{collection::UnorderedCollection, uri};
/// # let mut collection = UnorderedCollection::new();
///
/// collection.set_items(uri!("https://example.com"));
/// collection.set_item(uri!("https://example.com"));
/// # Ok(())
/// # }
/// ```
fn set_items<T>(&mut self, item: T) -> &mut Self
fn set_item<T>(&mut self, item: T) -> &mut Self
where
T: Into<AnyBase>,
{
@ -157,12 +157,12 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
/// # let mut collection = UnorderedCollection::new();
///
/// collection
/// .add_items(uri!("https://example.com/one"))
/// .add_items(uri!("https://example.com/two"));
/// .add_item(uri!("https://example.com/one"))
/// .add_item(uri!("https://example.com/two"));
/// # Ok(())
/// # }
/// ```
fn add_items<T>(&mut self, item: T) -> &mut Self
fn add_item<T>(&mut self, item: T) -> &mut Self
where
T: Into<AnyBase>,
{
@ -196,7 +196,7 @@ pub trait CollectionExt<Kind>: AsCollection<Kind> {
/// ```rust
/// # use activitystreams::{context, collection::UnorderedCollection};
/// # let mut collection = UnorderedCollection::new();
/// # collection.set_items(context());
/// # collection.set_item(context());
/// use activitystreams::prelude::*;
///
/// assert!(collection.items().is_some());

View file

@ -2147,11 +2147,11 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
/// # use activitystreams::{object::Video, uri};
/// # let mut video = Video::new();
///
/// video.set_replies(uri!("https://example.com"));
/// video.set_reply(uri!("https://example.com"));
/// # Ok(())
/// # }
/// ```
fn set_replies<T>(&mut self, replies: T) -> &mut Self
fn set_reply<T>(&mut self, replies: T) -> &mut Self
where
T: Into<AnyBase>,
{
@ -2197,12 +2197,12 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
/// # let mut video = Video::new();
///
/// video
/// .add_replies(uri!("https://example.com/one"))
/// .add_replies(uri!("https://example.com/two"));
/// .add_reply(uri!("https://example.com/one"))
/// .add_reply(uri!("https://example.com/two"));
/// # Ok(())
/// # }
/// ```
fn add_replies<T>(&mut self, replies: T) -> &mut Self
fn add_reply<T>(&mut self, replies: T) -> &mut Self
where
T: Into<AnyBase>,
{
@ -2239,7 +2239,7 @@ pub trait ObjectExt<Kind>: AsObject<Kind> {
/// # fn main() -> Result<(), anyhow::Error> {
/// # use activitystreams::{object::Video, uri};
/// # let mut video = Video::new();
/// # video.set_replies(uri!("https://example.com"));
/// # video.set_reply(uri!("https://example.com"));
/// #
/// use activitystreams::prelude::*;
///