MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / find

Method find

edit/src/main.rs:144–163  ·  view source on GitHub ↗
(&self, start: Cursor, pattern: u8)

Source from the content-addressed store, hash-verified

142 }
143
144 fn find(&self, start: Cursor, pattern: u8) -> Option<(Cursor, usize)> {
145 // Number of characters traversed
146 let mut ntraversed: usize = 0;
147 let mut cursor = start;
148 loop {
149 if let Some(c) = self.next(cursor) {
150 cursor = c;
151 } else {
152 break None;
153 }
154
155 // Count characters. NOTE: Assumes ASCII
156 ntraversed += 1;
157
158 // Get the byte at this location
159 if self.at(cursor) == pattern {
160 break Some((cursor, ntraversed));
161 }
162 }
163 }
164
165 // Reverse find, starting from the given cursor
166 // If found, returns a Cursor pointing to the location, and the number of characters traversed

Callers 2

varFunction · 0.45
mainFunction · 0.45

Calls 2

atMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected