Skip to main content

Edit

Struct Edit 

Source
pub struct Edit {
Show 20 fields pub file: String, pub entity: Option<EntityRef>, pub op: Option<String>, pub kind: Option<String>, pub ordinal: Option<usize>, pub content: Option<String>, pub old: Option<String>, pub new: Option<String>, pub all: bool, pub after: Option<String>, pub before: Option<String>, pub append: bool, pub into: Option<String>, pub delete: bool, pub allow_signature_change: bool, pub rename: Option<String>, pub expect: Option<String>, pub everywhere: bool, pub scope: Vec<String>, pub revert: Option<String>,
}

Fields§

§file: String

The file, relative to the repository root.

§entity: Option<EntityRef>

The entity to change: a function, class, method or key, by name. Parent.name (or Parent::name) picks a member of one class. Also takes pi-sem’s form, {name, entity_type?, parent_name?, ordinal?}.

§op: Option<String>

pi-sem’s verb: replace, insert_after, insert_before or delete, each about entity. The same edits are also spelled with content, after, before and delete directly.

§kind: Option<String>

The entity’s kind (function, method, class…) when names collide.

§ordinal: Option<usize>

0-based occurrence among entities that still match, in file order.

§content: Option<String>

The new source. With entity: the entity’s whole new text. With after, before or append: the entity to add. Alone, for a file that does not exist: the new file.

§old: Option<String>

Text to replace, inside entity when one is named, else in the whole file. Must match exactly once unless all is set.

§new: Option<String>

What old becomes.

§all: bool

Replace every occurrence of old, not exactly one.

§after: Option<String>

Add content as a new entity right after this one.

§before: Option<String>

Add content as a new entity right before this one.

§append: bool

Add content at the end of the file.

§into: Option<String>

Add content as the last member of this class (or other container), so a new method needs no anchor and nothing read first.

§delete: bool

Delete entity.

§allow_signature_change: bool

Let a replace rename the entity, change its kind or its visibility (export, pub, public…). Refused otherwise, since that is how an edit meant for one entity silently becomes a different one.

§rename: Option<String>

Rename entity (defined in file) to this name, and every identifier spelled like it in the code files of scope. Strings and comments are left alone; files without a grammar that mention it are listed.

§expect: Option<String>

The entity’s version as sem showed it (v:…): the edit is refused if the entity changed since, so two agents never overwrite each other’s version of one function.

§everywhere: bool

For rename: also rename the name where it appears as a whole word in comments and in docs and other text files (Markdown, reStructuredText, plain text). String literals are still left alone.

§scope: Vec<String>

For rename: the files to rename in, as git pathspec globs (src/**, *.py). Default: the whole repository.

§revert: Option<String>

Put entity back the way it was at this git ref (HEAD~3, a branch, a commit): its text at that ref replaces its text now, and nothing else in the file moves. A revert is a replace whose content comes from history, so every replace guard still applies.

Trait Implementations§

Source§

impl Clone for Edit

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Edit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Edit

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Edit

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Edit

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Edit

§

impl RefUnwindSafe for Edit

§

impl Send for Edit

§

impl Sync for Edit

§

impl Unpin for Edit

§

impl UnsafeUnpin for Edit

§

impl UnwindSafe for Edit

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.