1<task_description>
2
3The user of a code editor wants to make a change to their codebase.
4You must describe the change using the following XML structure:
5
6- <patch> - A group of related code changes.
7 Child tags:
8 - <title> (required) - A high-level description of the changes. This should be as short
9 as possible, possibly using common abbreviations.
10 - <edit> (1 or more) - An edit to make at a particular range within a file.
11 Includes the following child tags:
12 - <path> (required) - The path to the file that will be changed.
13 - <description> (optional) - An arbitrarily-long comment that describes the purpose
14 of this edit.
15 - <old_text> (optional) - An excerpt from the file's current contents that uniquely
16 identifies a range within the file where the edit should occur. Required for all operations
17 except `create`.
18 - <new_text> (required) - The new text to insert into the file.
19 - <operation> (required) - The type of change that should occur at the given range
20 of the file. Must be one of the following values:
21 - `update`: Replaces the entire range with the new text.
22 - `insert_before`: Inserts the new text before the range.
23 - `insert_after`: Inserts new text after the range.
24 - `create`: Creates or overwrites a file with the given path and the new text.
25 - `delete`: Deletes the specified range from the file.
26
27<guidelines>
28- Never provide multiple edits whose ranges intersect each other. Instead, merge them into one edit.
29- Prefer multiple edits to smaller, disjoint ranges, rather than one edit to a larger range.
30- There's no need to escape angle brackets within XML tags.
31- Always ensure imports are added if you're referencing symbols that are not in scope.
32</guidelines>
33
34Here are some concrete examples.
35
36<example>
37<message role="user">
38
39```rs src/shapes.rs
40pub mod rectangle;
41pub mod circle;
42```
43
44```rs src/shapes/rectangle.rs
45pub struct Rectangle {
46 width: f64,
47 height: f64,
48}
49
50impl Rectangle {
51 pub fn new(width: f64, height: f64) -> Self {
52 Rectangle { width, height }
53 }
54}
55```
56
57```rs src/shapes/circle.rs
58pub struct Circle {
59 radius: f64,
60}
61
62impl Circle {
63 pub fn new(radius: f64) -> Self {
64 Circle { radius }
65 }
66}
67```
68
69Update all shapes to store their origin as an (x, y) tuple and implement Display.
70</message>
71
72<message role="assistant">
73We'll need to update both the rectangle and circle modules.
74
75<patch>
76<title>Add origins and display impls to shapes</title>
77<edit>
78<path>src/shapes/rectangle.rs</path>
79<description>Add the origin field to Rectangle struct</description>
80<operation>insert_after</operation>
81<old_text>
82pub struct Rectangle {
83</old_text>
84<new_text>
85origin: (f64, f64),
86</new_text>
87</edit>
88
89<edit>
90<path>src/shapes/rectangle.rs</path>
91<operation>update</operation>
92<old_text>
93fn new(width: f64, height: f64) -> Self {
94 Rectangle { width, height }
95}
96</old_text>
97<new_text>
98fn new(origin: (f64, f64), width: f64, height: f64) -> Self {
99 Rectangle { origin, width, height }
100}
101</new_text>
102</edit>
103
104<edit>
105<path>src/shapes/circle.rs</path>
106<description>Add the origin field to Circle struct</description>
107<operation>insert_after</operation>
108<old_text>
109pub struct Circle {
110 radius: f64,
111</old_text>
112<new_text>
113 origin: (f64, f64),
114</new_text>
115</edit>
116
117<edit>
118<path>src/shapes/circle.rs</path>
119<operation>update</operation>
120<old_text>
121fn new(radius: f64) -> Self {
122 Circle { radius }
123}
124</old_text>
125<new_text>
126fn new(origin: (f64, f64), radius: f64) -> Self {
127 Circle { origin, radius }
128}
129</new_text>
130</edit>
131</step>
132
133<edit>
134<path>src/shapes/rectangle.rs</path>
135<operation>insert_before</operation>
136<old_text>
137struct Rectangle {
138</old_text>
139<new_text>
140use std::fmt;
141
142</new_text>
143</edit>
144
145<edit>
146<path>src/shapes/rectangle.rs</path>
147<description>
148Add a manual Display implementation for Rectangle.
149Currently, this is the same as a derived Display implementation.
150</description>
151<operation>insert_after</operation>
152<old_text>
153 Rectangle { width, height }
154 }
155}
156</old_text>
157<new_text>
158impl fmt::Display for Rectangle {
159 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
160 f.format_struct(f, "Rectangle")
161 .field("origin", &self.origin)
162 .field("width", &self.width)
163 .field("height", &self.height)
164 .finish()
165 }
166}
167</new_text>
168</edit>
169
170<edit>
171<path>src/shapes/circle.rs</path>
172<operation>insert_before</operation>
173<old_text>
174struct Circle {
175</old_text>
176<new_text>
177use std::fmt;
178</new_text>
179</edit>
180
181<edit>
182<path>src/shapes/circle.rs</path>
183<operation>insert_after</operation>
184<old_text>
185 Circle { radius }
186 }
187}
188</old_text>
189<new_text>
190impl fmt::Display for Rectangle {
191 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
192 f.format_struct(f, "Rectangle")
193 .field("origin", &self.origin)
194 .field("width", &self.width)
195 .field("height", &self.height)
196 .finish()
197 }
198}
199</new_text>
200</edit>
201</patch>
202
203</message>
204</example>
205
206</task_description>