file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
callback.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Base classes to work with IDL callbacks. use dom::bindings::error::{Error, Fallible}; use dom::bindings::glob...
<T: CallbackContainer>(callback: &T, handling: ExceptionHandling) -> CallSetup { let global = global_root_from_object(callback.callback()); let cx = global.r().get_cx(); unsafe { JS_BeginRequest(cx); } let exception_compartment = unsafe { GetGlobalForObje...
new
identifier_name
vec.rs
use super::{AssertionFailure, Spec}; pub trait VecAssertions { fn has_length(&mut self, expected: usize); fn is_empty(&mut self); } impl<'s, T> VecAssertions for Spec<'s, Vec<T>> { /// Asserts that the length of the subject vector is equal to the provided length. The subject /// type must be of `Vec`....
} } #[cfg(test)] mod tests { use super::super::prelude::*; #[test] fn should_not_panic_if_vec_length_matches_expected() { let test_vec = vec![1, 2, 3]; assert_that(&test_vec).has_length(3); } #[test] #[should_panic(expected = "\n\texpected: vec to have length <1>\n\t but...
{ AssertionFailure::from_spec(self) .with_expected(format!("an empty vec")) .with_actual(format!("a vec with length <{:?}>", subject.len())) .fail(); }
conditional_block
vec.rs
use super::{AssertionFailure, Spec}; pub trait VecAssertions { fn has_length(&mut self, expected: usize); fn is_empty(&mut self); } impl<'s, T> VecAssertions for Spec<'s, Vec<T>> { /// Asserts that the length of the subject vector is equal to the provided length. The subject /// type must be of `Vec`....
fn has_length(&mut self, expected: usize) { let length = self.subject.len(); if length!= expected { AssertionFailure::from_spec(self) .with_expected(format!("vec to have length <{}>", expected)) .with_actual(format!("<{}>", length)) .fail(); ...
random_line_split
vec.rs
use super::{AssertionFailure, Spec}; pub trait VecAssertions { fn has_length(&mut self, expected: usize); fn is_empty(&mut self); } impl<'s, T> VecAssertions for Spec<'s, Vec<T>> { /// Asserts that the length of the subject vector is equal to the provided length. The subject /// type must be of `Vec`....
#[test] fn should_not_panic_if_vec_was_expected_to_be_empty_and_is() { let test_vec: Vec<u8> = vec![]; assert_that(&test_vec).is_empty(); } #[test] #[should_panic(expected = "\n\texpected: an empty vec\ \n\t but was: a vec with length <1>")] fn should_panic_...
{ let test_vec = vec![1, 2, 3]; assert_that(&test_vec).has_length(1); }
identifier_body
vec.rs
use super::{AssertionFailure, Spec}; pub trait VecAssertions { fn has_length(&mut self, expected: usize); fn is_empty(&mut self); } impl<'s, T> VecAssertions for Spec<'s, Vec<T>> { /// Asserts that the length of the subject vector is equal to the provided length. The subject /// type must be of `Vec`....
() { let test_vec = vec![1, 2, 3]; assert_that(&test_vec).has_length(3); } #[test] #[should_panic(expected = "\n\texpected: vec to have length <1>\n\t but was: <3>")] fn should_panic_if_vec_length_does_not_match_expected() { let test_vec = vec![1, 2, 3]; assert_that(&tes...
should_not_panic_if_vec_length_matches_expected
identifier_name
dragon.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usize, /*exp*/ i16) { assert!(d.mant > 0); assert!(d.minus > 0); assert!(d.plus > 0); assert!(d.mant.checked_add(d.plus).is_some()); assert!(d.mant.checked_sub(d.minus).is_some()); // estimate `k_0` from original inputs satisfying `10^(k...
format_exact
identifier_name
dragon.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
static POW10TO64: [Digit; 7] = [0, 0, 0xbf6a1f01, 0x6e38ed64, 0xdaa797ed, 0xe93ff9f4, 0x184f03]; static POW10TO128: [Digit; 14] = [0, 0, 0, 0, 0x2e953e01, 0x3df9909, 0xf1538fd, 0x2374e42f, 0xd3cff5ec, 0xc404dc08, 0xbccdb0da, 0xa6337f19, 0xe91f2603, 0x24e]; static POW10TO256: [Digit; 27] = [0, 0, 0, 0, 0, 0...
static POW10TO32: [Digit; 4] = [0, 0x85acef81, 0x2d6d415b, 0x4ee];
random_line_split
dragon.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// `a.cmp(&b) < rounding` is `if d.inclusive {a <= b} else {a < b}` let rounding = if d.inclusive {Ordering::Greater} else {Ordering::Equal}; // estimate `k_0` from original inputs satisfying `10^(k_0-1) < high <= 10^(k_0+1)`. // the tight bound `k` satisfying `10^(k-1) < high <= 10^k` is calculated la...
{ // the number `v` to format is known to be: // - equal to `mant * 2^exp`; // - preceded by `(mant - 2 * minus) * 2^exp` in the original type; and // - followed by `(mant + 2 * plus) * 2^exp` in the original type. // // obviously, `minus` and `plus` cannot be zero. (for infinities, we use out-o...
identifier_body
dragon.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
else { buf.len() }; if len > 0 { // cache `(2, 4, 8) * scale` for digit generation. // (this can be expensive, so do not calculate them when the buffer is empty.) let mut scale2 = scale.clone(); scale2.mul_pow2(1); let mut scale4 = scale.clone(); scale4.mul_pow2(2); ...
{ (k - limit) as usize }
conditional_block
scalar.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashMap; use std::usize; use test::{black_box, Bencher}; use tipb::ScalarFuncSig; fn get_scalar_args_with_match(sig: ScalarFuncSig) -> (usize, usize) { // Only select some functions to benchmark let (min_args, max_args) = matc...
(0, 0) } #[bench] fn bench_get_scalar_args_with_match(b: &mut Bencher) { b.iter(|| { for _ in 0..1000 { black_box(get_scalar_args_with_match(black_box(ScalarFuncSig::AbsInt))); } }) } #[bench] fn bench_get_scalar_args_with_map(b: &mut Bencher) { let m = init_scalar_args_m...
{ return (min_args, max_args); }
conditional_block
scalar.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashMap; use std::usize; use test::{black_box, Bencher}; use tipb::ScalarFuncSig; fn
(sig: ScalarFuncSig) -> (usize, usize) { // Only select some functions to benchmark let (min_args, max_args) = match sig { ScalarFuncSig::LtInt => (2, 2), ScalarFuncSig::CastIntAsInt => (1, 1), ScalarFuncSig::IfInt => (3, 3), ScalarFuncSig::JsonArraySig => (0, usize::MAX), ...
get_scalar_args_with_match
identifier_name
scalar.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashMap; use std::usize; use test::{black_box, Bencher}; use tipb::ScalarFuncSig; fn get_scalar_args_with_match(sig: ScalarFuncSig) -> (usize, usize) { // Only select some functions to benchmark let (min_args, max_args) = matc...
{ let m = init_scalar_args_map(); b.iter(|| { for _ in 0..1000 { black_box(get_scalar_args_with_map( black_box(&m), black_box(ScalarFuncSig::AbsInt), )); } }) }
identifier_body
scalar.rs
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. use collections::HashMap; use std::usize; use test::{black_box, Bencher}; use tipb::ScalarFuncSig; fn get_scalar_args_with_match(sig: ScalarFuncSig) -> (usize, usize) { // Only select some functions to benchmark let (min_args, max_args) = matc...
} fn init_scalar_args_map() -> HashMap<ScalarFuncSig, (usize, usize)> { let mut m: HashMap<ScalarFuncSig, (usize, usize)> = HashMap::default(); let tbls = vec![ (ScalarFuncSig::LtInt, (2, 2)), (ScalarFuncSig::CastIntAsInt, (1, 1)), (ScalarFuncSig::IfInt, (3, 3)), (ScalarFuncSig...
_ => (0, 0), }; (min_args, max_args)
random_line_split
libstdbuf.rs
#![crate_name = "libstdbuf"] #![crate_type = "staticlib"] #![feature(core, libc, os)] extern crate libc; use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf}; use std::ptr; use std::os; #[path = "../common/util.rs"] #[macro_use] mod util; extern { static stdin: *mut FILE; static stdout: *...
pub extern fn stdbuf() { if let Some(val) = os::getenv("_STDBUF_E") { set_buffer(stderr, val.as_slice()); } if let Some(val) = os::getenv("_STDBUF_I") { set_buffer(stdin, val.as_slice()); } if let Some(val) = os::getenv("_STDBUF_O") { set_buffer(stdout, val.as_slice()); ...
#[no_mangle]
random_line_split
libstdbuf.rs
#![crate_name = "libstdbuf"] #![crate_type = "staticlib"] #![feature(core, libc, os)] extern crate libc; use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf}; use std::ptr; use std::os; #[path = "../common/util.rs"] #[macro_use] mod util; extern { static stdin: *mut FILE; static stdout: *...
{ if let Some(val) = os::getenv("_STDBUF_E") { set_buffer(stderr, val.as_slice()); } if let Some(val) = os::getenv("_STDBUF_I") { set_buffer(stdin, val.as_slice()); } if let Some(val) = os::getenv("_STDBUF_O") { set_buffer(stdout, val.as_slice()); } }
identifier_body
libstdbuf.rs
#![crate_name = "libstdbuf"] #![crate_type = "staticlib"] #![feature(core, libc, os)] extern crate libc; use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf}; use std::ptr; use std::os; #[path = "../common/util.rs"] #[macro_use] mod util; extern { static stdin: *mut FILE; static stdout: *...
}
{ set_buffer(stdout, val.as_slice()); }
conditional_block
libstdbuf.rs
#![crate_name = "libstdbuf"] #![crate_type = "staticlib"] #![feature(core, libc, os)] extern crate libc; use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf}; use std::ptr; use std::os; #[path = "../common/util.rs"] #[macro_use] mod util; extern { static stdin: *mut FILE; static stdout: *...
() { if let Some(val) = os::getenv("_STDBUF_E") { set_buffer(stderr, val.as_slice()); } if let Some(val) = os::getenv("_STDBUF_I") { set_buffer(stdin, val.as_slice()); } if let Some(val) = os::getenv("_STDBUF_O") { set_buffer(stdout, val.as_slice()); } }
stdbuf
identifier_name
main.rs
extern crate rustc_serialize; extern crate hyper; use rustc_serialize::json; use rustc_serialize::json::Json; #[macro_use] extern crate nickel; use nickel::status::StatusCode; use nickel::{Nickel, HttpRouter, MediaType, JsonBody}; #[derive(RustcDecodable, RustcEncodable)] struct
{ status: i32, title: String, } fn main() { let mut server = Nickel::new(); let mut router = Nickel::router(); // index router.get("/api/todos", middleware! { |_, mut _res| let mut v: Vec<Todo> = vec![]; let todo1 = Todo{ status: 0, title: "Shopping".to_string(), }; v.push(tod...
Todo
identifier_name
main.rs
extern crate rustc_serialize; extern crate hyper; use rustc_serialize::json; use rustc_serialize::json::Json; #[macro_use] extern crate nickel; use nickel::status::StatusCode; use nickel::{Nickel, HttpRouter, MediaType, JsonBody}; #[derive(RustcDecodable, RustcEncodable)] struct Todo { status: i32, title: String...
let todo = _req.json_as::<Todo>().unwrap(); let status = todo.status; let title = todo.title.to_string(); println!("create status {:?} title {}", status, title); let json_obj = Json::from_str("{}").unwrap(); _res.set(MediaType::Json); _res.set(StatusCode::Created); return _res.send(j...
// create router.post("/api/todos", middleware! { |_req, mut _res|
random_line_split
issue-14845.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x = X { a: [0] }; let _f = &x.a as *mut u8; //~^ ERROR mismatched types //~| expected `*mut u8` //~| found `&[u8; 1]` //~| expected u8 //~| found array of 1 elements let local = [0u8]; let _v = &local as *mut u8; //~^ ERROR mismatched types //~| expected `*mut u8` ...
main
identifier_name
issue-14845.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
random_line_split
lib.rs
extern crate lexer; use lexer::{Item, StateFn, Lexer}; #[derive(Debug, PartialEq)] pub enum ItemType { Comma, Text, Comment, EOF } fn lex_text(l: &mut Lexer<ItemType>) -> Option<StateFn<ItemType>> { loop { if l.remaining_input().starts_with("//") { l.emit_nonempty(ItemType::T...
assert_eq!(items, expected_items); }
random_line_split
lib.rs
extern crate lexer; use lexer::{Item, StateFn, Lexer}; #[derive(Debug, PartialEq)] pub enum ItemType { Comma, Text, Comment, EOF } fn lex_text(l: &mut Lexer<ItemType>) -> Option<StateFn<ItemType>> { loop { if l.remaining_input().starts_with("//") { l.emit_nonempty(ItemType::T...
#[test] fn test_lexer() { let data = "foo,bar,baz // some comment\nfoo,bar"; let items = lexer::lex(data, lex_text); let expected_items = vec!( Item{typ: ItemType::Text, val: "foo", col: 1, lineno: 1}, Item{typ: ItemType::Comma, val: ",", col: 4, lineno: 1}, Item{typ: ItemType::Te...
{ loop { match l.next() { None => break, Some('\n') => { l.backup(); l.emit_nonempty(ItemType::Comment); l.next(); l.ignore(); return Some(StateFn(lex_text)); }, Some(_) => {}, ...
identifier_body
lib.rs
extern crate lexer; use lexer::{Item, StateFn, Lexer}; #[derive(Debug, PartialEq)] pub enum
{ Comma, Text, Comment, EOF } fn lex_text(l: &mut Lexer<ItemType>) -> Option<StateFn<ItemType>> { loop { if l.remaining_input().starts_with("//") { l.emit_nonempty(ItemType::Text); l.next(); return Some(StateFn(lex_comment)); } match l.n...
ItemType
identifier_name
lib.rs
extern crate lexer; use lexer::{Item, StateFn, Lexer}; #[derive(Debug, PartialEq)] pub enum ItemType { Comma, Text, Comment, EOF } fn lex_text(l: &mut Lexer<ItemType>) -> Option<StateFn<ItemType>> { loop { if l.remaining_input().starts_with("//") { l.emit_nonempty(ItemType::T...
, Some(_) => {}, } } l.emit_nonempty(ItemType::Comment); l.emit(ItemType::EOF); None } #[test] fn test_lexer() { let data = "foo,bar,baz // some comment\nfoo,bar"; let items = lexer::lex(data, lex_text); let expected_items = vec!( Item{typ: ItemType::Text, val: ...
{ l.backup(); l.emit_nonempty(ItemType::Comment); l.next(); l.ignore(); return Some(StateFn(lex_text)); }
conditional_block
mod.rs
extern crate sodiumoxide; extern crate serialize; extern crate sync; extern crate extra; use std::io::{Listener, Acceptor}; use std::io::{MemReader, BufReader}; use std::io::net::ip::{SocketAddr}; use std::io::net::tcp::{TcpListener, TcpStream}; use std::from_str::{from_str}; use capnp::message::{MallocMessageBuilder,...
else { fail!("sad :("); } client.write(comm::bare_msgs::HELLOBYTES); client.write(my_pubkey.get().key_bytes()); let client_pubkey = ~{ let reader = serialize_packed::new_reader_unbuffered(&mut client, DEFAULT_READER_OPTIONS).unwrap(); let pack = reader.get_root::<comm::pack_capnp::Pack::Reader>(); let ...
{ println!("Connection hello received"); }
conditional_block
mod.rs
extern crate sodiumoxide; extern crate serialize; extern crate sync; extern crate extra; use std::io::{Listener, Acceptor}; use std::io::{MemReader, BufReader}; use std::io::net::ip::{SocketAddr}; use std::io::net::tcp::{TcpListener, TcpStream}; use std::from_str::{from_str}; use capnp::message::{MallocMessageBuilder,...
() { sodiumoxide::init(); let (s_pubkey, s_privkey) = gen_keypair(); let a_pubkey = Arc::new(s_pubkey); let a_privkey = Arc::new(s_privkey); let bind_addr : SocketAddr = from_str("0.0.0.0:44944").unwrap(); let s_listener = TcpListener::bind(bind_addr).ok().expect("Failed to bind"); let mut s_acceptor = s_liste...
main
identifier_name
mod.rs
extern crate sodiumoxide; extern crate serialize; extern crate sync; extern crate extra; use std::io::{Listener, Acceptor}; use std::io::{MemReader, BufReader}; use std::io::net::ip::{SocketAddr}; use std::io::net::tcp::{TcpListener, TcpStream}; use std::from_str::{from_str}; use capnp::message::{MallocMessageBuilder,...
pub fn main() { sodiumoxide::init(); let (s_pubkey, s_privkey) = gen_keypair(); let a_pubkey = Arc::new(s_pubkey); let a_privkey = Arc::new(s_privkey); let bind_addr : SocketAddr = from_str("0.0.0.0:44944").unwrap(); let s_listener = TcpListener::bind(bind_addr).ok().expect("Failed to bind"); let mut s_accep...
{ }
identifier_body
mod.rs
extern crate sodiumoxide; extern crate serialize; extern crate sync; extern crate extra; use std::io::{Listener, Acceptor}; use std::io::{MemReader, BufReader}; use std::io::net::ip::{SocketAddr}; use std::io::net::tcp::{TcpListener, TcpStream}; use std::from_str::{from_str}; use capnp::message::{MallocMessageBuilder,...
let (s_pubkey, s_privkey) = gen_keypair(); let a_pubkey = Arc::new(s_pubkey); let a_privkey = Arc::new(s_privkey); let bind_addr : SocketAddr = from_str("0.0.0.0:44944").unwrap(); let s_listener = TcpListener::bind(bind_addr).ok().expect("Failed to bind"); let mut s_acceptor = s_listener.listen().ok().expect("F...
random_line_split
where-clauses-no-bounds-or-predicates.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn equal2<T>(_: &T, _: &T) -> bool where T: { //~^ ERROR each predicate in a `where` clause must have at least one bound true } fn main() { }
{ //~^ ERROR a `where` clause must have at least one predicate in it true }
identifier_body
where-clauses-no-bounds-or-predicates.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<T>(_: &T, _: &T) -> bool where T: { //~^ ERROR each predicate in a `where` clause must have at least one bound true } fn main() { }
equal2
identifier_name
where-clauses-no-bounds-or-predicates.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
true } fn equal2<T>(_: &T, _: &T) -> bool where T: { //~^ ERROR each predicate in a `where` clause must have at least one bound true } fn main() { }
// compile-flags: -Z parse-only fn equal1<T>(_: &T, _: &T) -> bool where { //~^ ERROR a `where` clause must have at least one predicate in it
random_line_split
vertex_outside.rs
use crate::mock_graph::{ arbitrary::{GuidedArbGraph, Limit}, MockVertex, TestGraph, }; use graphene::{ core::{Ensure, Graph}, impl_ensurer, }; use quickcheck::{Arbitrary, Gen}; use std::collections::HashSet; /// An arbitrary graph and a vertex that is guaranteed to not be in it. #[derive(Clone, Debug)] pub struct ...
<G: Gen>(g: &mut G, v_count: usize, e_count: usize) -> Self { let graph = Gr::arbitrary_fixed(g, v_count, e_count); // Find a vertex that isn't in the graph let mut v = MockVertex::arbitrary(g); while graph.graph().contains_vertex(v) { v = MockVertex::arbitrary(g); } Self(graph, v) } fn shrink_gu...
arbitrary_fixed
identifier_name
vertex_outside.rs
use crate::mock_graph::{ arbitrary::{GuidedArbGraph, Limit}, MockVertex, TestGraph, }; use graphene::{ core::{Ensure, Graph}, impl_ensurer, }; use quickcheck::{Arbitrary, Gen}; use std::collections::HashSet; /// An arbitrary graph and a vertex that is guaranteed to not be in it. #[derive(Clone, Debug)] pub struct ...
{ fn ensure_unvalidated(_c: Self::Ensured, _: ()) -> Self { unimplemented!() } fn validate(_c: &Self::Ensured, _: &()) -> bool { unimplemented!() } } impl_ensurer! { use<G> VertexOutside<G>: Ensure as (self.0): G where G: GuidedArbGraph, G::Graph: TestGraph, } impl<Gr> GuidedArbGraph for VertexOutside...
G::Graph: TestGraph,
random_line_split
vertex_outside.rs
use crate::mock_graph::{ arbitrary::{GuidedArbGraph, Limit}, MockVertex, TestGraph, }; use graphene::{ core::{Ensure, Graph}, impl_ensurer, }; use quickcheck::{Arbitrary, Gen}; use std::collections::HashSet; /// An arbitrary graph and a vertex that is guaranteed to not be in it. #[derive(Clone, Debug)] pub struct ...
fn shrink_guided(&self, limits: HashSet<Limit>) -> Box<dyn Iterator<Item = Self>> { let mut result = Vec::new(); // First shrink the graph, keeping only the shrunk ones where the vertex // stays invalid result.extend( self.0 .shrink_guided(limits) .filter(|g|!g.graph().contains_vertex(self.1)) ...
{ let graph = Gr::arbitrary_fixed(g, v_count, e_count); // Find a vertex that isn't in the graph let mut v = MockVertex::arbitrary(g); while graph.graph().contains_vertex(v) { v = MockVertex::arbitrary(g); } Self(graph, v) }
identifier_body
glib_gobject.rs
// GObject Introspection Rust bindings. // Copyright (C) 2014 Luis Araujo <araujoc.luisf@gmail.com> // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the Licen...
{} pub enum GMappedFile {} /* TODO: Get higher level structs for lists using generics */ pub struct GSList { data: GPointer, next: *GSList } pub struct GList { data: GPointer, next: *GList, prev: *GList } pub struct GError { domain: GQuark, code: c_int, message: *c_char }
GOptionGroup
identifier_name
glib_gobject.rs
// GObject Introspection Rust bindings. // Copyright (C) 2014 Luis Araujo <araujoc.luisf@gmail.com> // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the Licen...
pub struct GValue { /*< private >*/ g_type: GType, /* public for GTypeValueTable methods */ data: [GValueData,..2] } /* GLib */ pub enum GOptionGroup {} pub enum GMappedFile {} /* TODO: Get higher level structs for lists using generics */ pub struct GSList { data: GPointer, next: *GSList } ...
GValueDataVUInt64(u64), GValueDataVFloat(c_float), GValueDataVDouble(c_double), GValueDataVPointer(GPointer) }
random_line_split
labeled-break.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
break 'foobar; } } }
} } 'foobar: while 1 + 1 == 2 { loop {
random_line_split
labeled-break.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ 'foo: loop { loop { break 'foo; } } 'bar: for _ in 0..100 { loop { break 'bar; } } 'foobar: while 1 + 1 == 2 { loop { break 'foobar; } } }
identifier_body
labeled-break.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { 'foo: loop { loop { break 'foo; } } 'bar: for _ in 0..100 { loop { break 'bar; } } 'foobar: while 1 + 1 == 2 { loop { break 'foobar; } } }
main
identifier_name
objdetect.rs
//! Various object detection algorithms, such as Haar feature-based cascade //! classifier for object detection and histogram of oriented gradients (HOG). use super::core::*; use super::errors::*; use super::*; use failure::Error; use std::ffi::CString; use std::os::raw::{c_char, c_double, c_int}; use std::path::Path;...
impl Drop for HogDescriptor { fn drop(&mut self) { unsafe { cv_hog_drop(self.inner) } } }
/// Sets the SVM detector. pub fn set_svm_detector(&mut self, detector: SvmDetector) { unsafe { cv_hog_set_svm_detector(self.inner, detector.inner) } } }
random_line_split
objdetect.rs
//! Various object detection algorithms, such as Haar feature-based cascade //! classifier for object detection and histogram of oriented gradients (HOG). use super::core::*; use super::errors::*; use super::*; use failure::Error; use std::ffi::CString; use std::os::raw::{c_char, c_double, c_int}; use std::path::Path;...
{ inner: *mut CHogDescriptor, /// Hog parameters. pub params: HogParams, } unsafe impl Send for HogDescriptor {} extern "C" { fn cv_hog_new() -> *mut CHogDescriptor; fn cv_hog_drop(hog: *mut CHogDescriptor); fn cv_hog_set_svm_detector(hog: *mut CHogDescriptor, svm: *mut CSvmDetector); fn...
HogDescriptor
identifier_name
objdetect.rs
//! Various object detection algorithms, such as Haar feature-based cascade //! classifier for object detection and histogram of oriented gradients (HOG). use super::core::*; use super::errors::*; use super::*; use failure::Error; use std::ffi::CString; use std::os::raw::{c_char, c_double, c_int}; use std::path::Path;...
/// The default detection uses scale factor 1.1, minNeighbors 3, no min size /// or max size. pub fn detect_multiscale(&self, mat: &Mat) -> Vec<Rect> { self.detect_with_params(mat, 1.1, 3, Size2i::default(), Size2i::default()) } /// Detects the object using parameters specified. /// ...
{ if let Some(p) = path.as_ref().to_str() { let s = CString::new(p)?; if unsafe { cv_cascade_classifier_load(self.inner, (&s).as_ptr()) } { return Ok(()); } } Err(CvError::InvalidPath(path.as_ref().to_path_buf()).into()) }
identifier_body
objdetect.rs
//! Various object detection algorithms, such as Haar feature-based cascade //! classifier for object detection and histogram of oriented gradients (HOG). use super::core::*; use super::errors::*; use super::*; use failure::Error; use std::ffi::CString; use std::os::raw::{c_char, c_double, c_int}; use std::path::Path;...
Err(CvError::InvalidPath(path.as_ref().to_path_buf()).into()) } /// The default detection uses scale factor 1.1, minNeighbors 3, no min size /// or max size. pub fn detect_multiscale(&self, mat: &Mat) -> Vec<Rect> { self.detect_with_params(mat, 1.1, 3, Size2i::default(), Size2i::defau...
{ let s = CString::new(p)?; if unsafe { cv_cascade_classifier_load(self.inner, (&s).as_ptr()) } { return Ok(()); } }
conditional_block
users.rs
#![crate_name = "uu_users"] /* * This file is part of the uutils coreutils package. * * (c) KokaKiwi <kokakiwi@kokakiwi.net> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* last synced with: whoami (GNU coreutils) 8.22 */ // ...
} } endutxent(); } if!users.is_empty() { users.sort(); println!("{}", users.join(" ")); } }
{ unsafe { utmpxname(CString::new(filename).unwrap().as_ptr()); } let mut users = vec!(); unsafe { setutxent(); loop { let line = getutxent(); if line == ptr::null() { break; } if (*line).ut_type == USER_PROCESS...
identifier_body
users.rs
#![crate_name = "uu_users"] /* * This file is part of the uutils coreutils package. * * (c) KokaKiwi <kokakiwi@kokakiwi.net> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* last synced with: whoami (GNU coreutils) 8.22 */ // ...
users.sort(); println!("{}", users.join(" ")); } }
random_line_split
users.rs
#![crate_name = "uu_users"] /* * This file is part of the uutils coreutils package. * * (c) KokaKiwi <kokakiwi@kokakiwi.net> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* last synced with: whoami (GNU coreutils) 8.22 */ // ...
(_file: *const libc::c_char) -> libc::c_int { 0 } static NAME: &'static str = "users"; static VERSION: &'static str = env!("CARGO_PKG_VERSION"); pub fn uumain(args: Vec<String>) -> i32 { let mut opts = Options::new(); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version...
utmpxname
identifier_name
mod.rs
pub mod message; use std::net::TcpStream; use std::io; use std::io::{BufReader, Write, BufRead, Error}; use irc::message::{Message, MessageError}; /// Contains methods that handle common IRC functionality. pub trait Irc { /// Sends login credentials to the server. fn login(&mut self, username: &str, oauth: &s...
} /// Represents an error caused by reading a [`Message`] from the server. /// [`Message`]: message/enum.Message.html #[derive(Debug)] pub enum ReadLineError { /// The error is related to the connection. Connection(Error), /// The error is related to the attempt to parse the message received from the serv...
{ writeln!(self, "{}", string)?; self.flush() }
identifier_body
mod.rs
pub mod message; use std::net::TcpStream; use std::io; use std::io::{BufReader, Write, BufRead, Error}; use irc::message::{Message, MessageError}; /// Contains methods that handle common IRC functionality. pub trait Irc { /// Sends login credentials to the server. fn login(&mut self, username: &str, oauth: &s...
{ /// The error is related to the connection. Connection(Error), /// The error is related to the attempt to parse the message received from the server. Message(MessageError), } pub trait ReaderUtil { /// Reads a line directly from the connected server. fn read_line_raw(&mut self) -> Result...
ReadLineError
identifier_name
mod.rs
pub mod message; use std::net::TcpStream; use std::io; use std::io::{BufReader, Write, BufRead, Error}; use irc::message::{Message, MessageError}; /// Contains methods that handle common IRC functionality. pub trait Irc { /// Sends login credentials to the server. fn login(&mut self, username: &str, oauth: &s...
/// Represents an error caused by reading a [`Message`] from the server. /// [`Message`]: message/enum.Message.html #[derive(Debug)] pub enum ReadLineError { /// The error is related to the connection. Connection(Error), /// The error is related to the attempt to parse the message received from the server....
fn send_line(&mut self, string: &str) -> Result<(), io::Error> { writeln!(self, "{}", string)?; self.flush() } }
random_line_split
anyid.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::num::NonZeroU64; #[cfg(any(test, feature = "for-tests"))] use quickcheck_arbitrary_derive::Arbitrary; use serde_derive::Deseriali...
() -> Self { Self::AnyFileContentId(AnyFileContentId::default()) } } #[auto_wire] #[derive(Clone, Default, Debug, Serialize, Deserialize, Eq, PartialEq)] #[cfg_attr(any(test, feature = "for-tests"), derive(Arbitrary))] pub struct LookupRequest { #[id(1)] pub id: AnyId, #[id(2)] pub bubble_i...
default
identifier_name
anyid.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::num::NonZeroU64; #[cfg(any(test, feature = "for-tests"))] use quickcheck_arbitrary_derive::Arbitrary; use serde_derive::Deseriali...
blake2_hash!(BonsaiChangesetId); #[auto_wire] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] #[cfg_attr(any(test, feature = "for-tests"), derive(Arbitrary))] pub enum AnyId { #[id(1)] AnyFileContentId(AnyFileContentId), #[id(2)] HgFilenodeId(HgId), #[id(3)] HgTreeId(HgId),...
random_line_split
anyid.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::num::NonZeroU64; #[cfg(any(test, feature = "for-tests"))] use quickcheck_arbitrary_derive::Arbitrary; use serde_derive::Deseriali...
} #[auto_wire] #[derive(Clone, Default, Debug, Serialize, Deserialize, Eq, PartialEq)] #[cfg_attr(any(test, feature = "for-tests"), derive(Arbitrary))] pub struct LookupRequest { #[id(1)] pub id: AnyId, #[id(2)] pub bubble_id: Option<NonZeroU64>, /// If present and the original id is not, lookup w...
{ Self::AnyFileContentId(AnyFileContentId::default()) }
identifier_body
cargo_pkgid.rs
use ops; use core::{MultiShell, Source, PackageIdSpec}; use sources::{PathSource}; use util::{CargoResult, human}; pub fn pkgid(manifest_path: &Path, spec: Option<&str>, _shell: &mut MultiShell) -> CargoResult<PackageIdSpec> { let mut source = try!(PathSource::for_path(&manifest_path.dir_...
Ok(PackageIdSpec::from_package_id(pkgid)) }
random_line_split
cargo_pkgid.rs
use ops; use core::{MultiShell, Source, PackageIdSpec}; use sources::{PathSource}; use util::{CargoResult, human}; pub fn pkgid(manifest_path: &Path, spec: Option<&str>, _shell: &mut MultiShell) -> CargoResult<PackageIdSpec>
{ let mut source = try!(PathSource::for_path(&manifest_path.dir_path())); try!(source.update()); let package = try!(source.get_root_package()); let lockfile = package.get_root().join("Cargo.lock"); let source_id = package.get_package_id().get_source_id(); let resolve = match try!(ops::load_lock...
identifier_body
cargo_pkgid.rs
use ops; use core::{MultiShell, Source, PackageIdSpec}; use sources::{PathSource}; use util::{CargoResult, human}; pub fn
(manifest_path: &Path, spec: Option<&str>, _shell: &mut MultiShell) -> CargoResult<PackageIdSpec> { let mut source = try!(PathSource::for_path(&manifest_path.dir_path())); try!(source.update()); let package = try!(source.get_root_package()); let lockfile = package.get_root().j...
pkgid
identifier_name
webglbuffer.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::codegen::Bindings:...
} pub fn usage(&self) -> u32 { self.usage.get() } } impl Drop for WebGLBuffer { fn drop(&mut self) { self.mark_for_deletion(true); } }
{ self.delete(false); }
conditional_block
webglbuffer.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::codegen::Bindings:...
assert!(self.is_deleted()); let context = self.upcast::<WebGLObject>().context(); let cmd = WebGLCommand::DeleteBuffer(self.id); if fallible { context.send_command_ignored(cmd); } else { context.send_command(cmd); } } pub fn is_marked_for_...
fn delete(&self, fallible: bool) {
random_line_split
webglbuffer.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::codegen::Bindings:...
}
{ self.mark_for_deletion(true); }
identifier_body
webglbuffer.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::codegen::Bindings:...
(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateBuffer(sender)); receiver .recv() .unwrap() .map(|id| WebGLBuffer::new(context, id)) } pub fn new(con...
maybe_new
identifier_name
main.rs
#![allow(unused_must_use)] extern crate pad; #[macro_use] extern crate quicli; extern crate reqwest; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate term; use pad::PadStr; use reqwest::Url; use std::process; use std::str; use quicli::prelude::*; #[macro_use] mod mac...
" = \"{}\" \t(downloads: {})\n", cr.max_version, cr.downloads ); if!quiet { cr.description .as_ref() .map(|description| p_yellow!(t, " -> {}\n", description.clone().trim())); cr.documentation .as_ref() .map(|documentation| p...
fn show_crate(t: &mut Box<term::StdoutTerminal>, cr: &EncodableCrate, quiet: bool, max_len: usize) { p_green!(t, "{}", cr.name.pad_to_width(max_len)); p_white!( t,
random_line_split
main.rs
#![allow(unused_must_use)] extern crate pad; #[macro_use] extern crate quicli; extern crate reqwest; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate term; use pad::PadStr; use reqwest::Url; use std::process; use std::str; use quicli::prelude::*; #[macro_use] mod mac...
} main!(|args: Cli| { let Cli::Ssearch { query, page, limit, quiet, recent, } = args; let mut t = term::stdout().unwrap(); // TODO: Add decoding of updated_at and allow to use it for sorting let (total, crates) = query_crates_io(&query, page, limit, recent...
{ cr.description .as_ref() .map(|description| p_yellow!(t, " -> {}\n", description.clone().trim())); cr.documentation .as_ref() .map(|documentation| p_white!(t, " docs: {}\n", documentation)); cr.homepage .as_ref() .map(|...
conditional_block
main.rs
#![allow(unused_must_use)] extern crate pad; #[macro_use] extern crate quicli; extern crate reqwest; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate term; use pad::PadStr; use reqwest::Url; use std::process; use std::str; use quicli::prelude::*; #[macro_use] mod mac...
( query: &str, page: usize, per_page: usize, recent: bool, ) -> Result<(i32, Vec<EncodableCrate>)> { let sort = if recent { "recent-downloads" } else { "downloads" }; let url = Url::parse_with_params( "https://crates.io/api/v1/crates", &[ ("q",...
query_crates_io
identifier_name
compositionevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::CompositionEventBinding::{ self, CompositionEventMethods, }; use...
#[allow(non_snake_case)] pub fn Constructor( window: &Window, type_: DOMString, init: &CompositionEventBinding::CompositionEventInit, ) -> Fallible<DomRoot<CompositionEvent>> { let event = CompositionEvent::new( window, type_, init.parent...
{ let ev = reflect_dom_object( Box::new(CompositionEvent { uievent: UIEvent::new_inherited(), data: data, }), window, CompositionEventBinding::Wrap, ); ev.uievent .InitUIEvent(type_, can_bubble, cancelabl...
identifier_body
compositionevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::CompositionEventBinding::{ self, CompositionEventMethods, }; use...
uievent: UIEvent::new_inherited(), data: DOMString::new(), } } pub fn new_uninitialized(window: &Window) -> DomRoot<CompositionEvent> { reflect_dom_object( Box::new(CompositionEvent::new_inherited()), window, CompositionEventBinding::W...
impl CompositionEvent { pub fn new_inherited() -> CompositionEvent { CompositionEvent {
random_line_split
compositionevent.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::CompositionEventBinding::{ self, CompositionEventMethods, }; use...
{ uievent: UIEvent, data: DOMString, } impl CompositionEvent { pub fn new_inherited() -> CompositionEvent { CompositionEvent { uievent: UIEvent::new_inherited(), data: DOMString::new(), } } pub fn new_uninitialized(window: &Window) -> DomRoot<CompositionEve...
CompositionEvent
identifier_name
main.rs
use std::cmp::Ord; use std::cmp::Ordering::{Less, Equal, Greater}; fn chop<T: Ord>(item : T, slice : &[T]) -> i32
} width /= 2; } return -1; } fn main() { println!("{}", chop(3, &[1,3,5])); } #[test] fn test_chop() { assert_eq!(-1, chop(3, &[])); assert_eq!(-1, chop(3, &[1])); assert_eq!(0, chop(1, &[1])); assert_eq!(0, chop(1, &[1, 3, 5])); assert_eq!(1, chop(3, &[1, 3, 5]));...
{ let length = slice.len(); // Catch empty slices if length < 1 { return -1; } let mut width = length; let mut low = 0; while width > 0 { let mid_index = low + (width / 2); let comparison = item.cmp(&slice[mid_index]); match comparison { Less => ...
identifier_body
main.rs
use std::cmp::Ord; use std::cmp::Ordering::{Less, Equal, Greater}; fn chop<T: Ord>(item : T, slice : &[T]) -> i32 { let length = slice.len(); // Catch empty slices if length < 1 { return -1; } let mut width = length; let mut low = 0; while width > 0 { let mid_index = low +...
return -1; } fn main() { println!("{}", chop(3, &[1,3,5])); } #[test] fn test_chop() { assert_eq!(-1, chop(3, &[])); assert_eq!(-1, chop(3, &[1])); assert_eq!(0, chop(1, &[1])); assert_eq!(0, chop(1, &[1, 3, 5])); assert_eq!(1, chop(3, &[1, 3, 5])); assert_eq!(2, chop(5, &[1, 3, 5...
Equal => return mid_index as i32 } width /= 2; }
random_line_split
main.rs
use std::cmp::Ord; use std::cmp::Ordering::{Less, Equal, Greater}; fn
<T: Ord>(item : T, slice : &[T]) -> i32 { let length = slice.len(); // Catch empty slices if length < 1 { return -1; } let mut width = length; let mut low = 0; while width > 0 { let mid_index = low + (width / 2); let comparison = item.cmp(&slice[mid_index]); ...
chop
identifier_name
borrowck-unboxed-closures.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{}
identifier_body
borrowck-unboxed-closures.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
f(1, 2); //~ ERROR use of moved value } fn main() {}
random_line_split
borrowck-unboxed-closures.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<F:FnMut(isize, isize) -> isize>(f: F) { f(1, 2); //~ ERROR cannot borrow immutable local variable } fn c<F:FnOnce(isize, isize) -> isize>(f: F) { f(1, 2); f(1, 2); //~ ERROR use of moved value } fn main() {}
b
identifier_name
rfc2782.rs
//! Record data from [RFC 2782]. //! //! This RFC defines the Srv record type. //! //! [RFC 2782]: https://tools.ietf.org/html/rfc2782 use std::fmt; use ::bits::{Composer, ComposeResult, DNameSlice, ParsedRecordData, Parser, ParseResult, RecordData, DName, DNameBuf, ParsedDName}; use ::iana::Rtype; use ::...
(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {} {} {}", self.priority, self.weight, self.port, self.target) } }
fmt
identifier_name
rfc2782.rs
//! Record data from [RFC 2782]. //! //! This RFC defines the Srv record type. //! //! [RFC 2782]: https://tools.ietf.org/html/rfc2782 use std::fmt; use ::bits::{Composer, ComposeResult, DNameSlice, ParsedRecordData, Parser, ParseResult, RecordData, DName, DNameBuf, ParsedDName}; use ::iana::Rtype; use ::...
} } impl<N: DName + fmt::Display> fmt::Display for Srv<N> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {} {} {}", self.priority, self.weight, self.port, self.target) } }
{ Ok(None) }
conditional_block
rfc2782.rs
//! Record data from [RFC 2782]. //! //! This RFC defines the Srv record type. //! //! [RFC 2782]: https://tools.ietf.org/html/rfc2782 use std::fmt; use ::bits::{Composer, ComposeResult, DNameSlice, ParsedRecordData, Parser, ParseResult, RecordData, DName, DNameBuf, ParsedDName}; use ::iana::Rtype; use ::...
} impl<N: DName + fmt::Display> fmt::Display for Srv<N> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} {} {} {}", self.priority, self.weight, self.port, self.target) } }
{ if rtype == Rtype::Srv { Srv::parse_always(parser).map(Some) } else { Ok(None) } }
identifier_body
rfc2782.rs
//! Record data from [RFC 2782]. //! //! This RFC defines the Srv record type. //! //! [RFC 2782]: https://tools.ietf.org/html/rfc2782 use std::fmt; use ::bits::{Composer, ComposeResult, DNameSlice, ParsedRecordData, Parser, ParseResult, RecordData, DName, DNameBuf, ParsedDName}; use ::iana::Rtype; use ::...
priority: u16, weight: u16, port: u16, target: N } impl<N: DName> Srv<N> { pub fn new(priority: u16, weight: u16, port: u16, target: N) -> Self { Srv { priority: priority, weight: weight, port: port, target: target } } pub fn priority(&self) -> u16 { self.priority } pub fn weig...
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct Srv<N: DName> {
random_line_split
interner.rs
use std::cmp::Ordering; use std::fmt; use std::hash::{Hash, Hasher}; use std::ops::Deref; use Result; use base::fnv::FnvMap; use gc::{GcPtr, Gc, Traverseable}; use array::Str; /// Interned strings which allow for fast equality checks and hashing #[derive(Copy, Clone, Eq)] pub struct InternedStr(GcPtr<Str>); impl Par...
}
{ write!(f, "{}", &self[..]) }
identifier_body
interner.rs
use std::cmp::Ordering; use std::fmt; use std::hash::{Hash, Hasher}; use std::ops::Deref; use Result; use base::fnv::FnvMap; use gc::{GcPtr, Gc, Traverseable}; use array::Str; /// Interned strings which allow for fast equality checks and hashing #[derive(Copy, Clone, Eq)] pub struct InternedStr(GcPtr<Str>); impl Par...
(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "InternedStr({:?})", self.0) } } impl fmt::Display for InternedStr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", &self[..]) } }
fmt
identifier_name
interner.rs
use std::cmp::Ordering; use std::fmt; use std::hash::{Hash, Hasher}; use std::ops::Deref; use Result; use base::fnv::FnvMap; use gc::{GcPtr, Gc, Traverseable}; use array::Str; /// Interned strings which allow for fast equality checks and hashing #[derive(Copy, Clone, Eq)] pub struct InternedStr(GcPtr<Str>); impl Par...
impl PartialOrd for InternedStr { fn partial_cmp(&self, other: &InternedStr) -> Option<Ordering> { self.as_ptr().partial_cmp(&other.as_ptr()) } } impl Ord for InternedStr { fn cmp(&self, other: &InternedStr) -> Ordering { self.as_ptr().cmp(&other.as_ptr()) } } impl Hash for InternedStr...
random_line_split
app.rs
use clap::{App, AppSettings, Arg, ArgGroup, SubCommand}; pub fn build() -> App<'static,'static> { App::new(crate_name!()) .about(crate_description!()) .version(crate_version!()) .setting(AppSettings::SubcommandRequired) .setting(AppSettings::VersionlessSubcommands) .subcommand(Su...
.short("f") .takes_value(true)) .arg(Arg::with_name("description") .help("Prints results with description") .long("description") .short("d") .requires("filter")) .group(ArgGroup::with_name("modes") ...
.long("filter")
random_line_split
app.rs
use clap::{App, AppSettings, Arg, ArgGroup, SubCommand}; pub fn build() -> App<'static,'static>
.arg(Arg::with_name("description") .help("Prints results with description") .long("description") .short("d") .requires("filter")) .group(ArgGroup::with_name("modes") .args(&["convert", "filter"]) .required(tr...
{ App::new(crate_name!()) .about(crate_description!()) .version(crate_version!()) .setting(AppSettings::SubcommandRequired) .setting(AppSettings::VersionlessSubcommands) .subcommand(SubCommand::with_name("digraph") .about("Digraph lookup and resolution") ...
identifier_body
app.rs
use clap::{App, AppSettings, Arg, ArgGroup, SubCommand}; pub fn
() -> App<'static,'static> { App::new(crate_name!()) .about(crate_description!()) .version(crate_version!()) .setting(AppSettings::SubcommandRequired) .setting(AppSettings::VersionlessSubcommands) .subcommand(SubCommand::with_name("digraph") .about("Digraph lookup and r...
build
identifier_name
sip.rs
/* Copyright (C) 2019-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
#[no_mangle] pub unsafe extern "C" fn rs_sip_register_parser() { let default_port = CString::new("5060").unwrap(); let parser = RustParser { name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char, default_port: default_port.as_ptr(), ipproto: core::IPPROTO_UDP, probe_ts: Some...
export_tx_data_get!(rs_sip_get_tx_data, SIPTransaction); const PARSER_NAME: &'static [u8] = b"sip\0";
random_line_split
sip.rs
/* Copyright (C) 2019-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
(id: u64) -> SIPTransaction { SIPTransaction { id: id, de_state: None, request: None, response: None, request_line: None, response_line: None, events: std::ptr::null_mut(), tx_data: applayer::AppLayerTxData::new(), ...
new
identifier_name
sip.rs
/* Copyright (C) 2019-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
fn new_tx(&mut self) -> SIPTransaction { self.tx_id += 1; SIPTransaction::new(self.tx_id) } fn get_tx_by_id(&mut self, tx_id: u64) -> Option<&SIPTransaction> { self.transactions.iter().find(|&tx| tx.id == tx_id + 1) } fn free_tx(&mut self, tx_id: u64) { let tx = s...
{ self.transactions.clear(); }
identifier_body
sip.rs
/* Copyright (C) 2019-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
} fn set_event(&mut self, event: SIPEvent) { if let Some(tx) = self.transactions.last_mut() { let ev = event as u8; core::sc_app_layer_decoder_events_set_event_raw(&mut tx.events, ev); } } fn parse_request(&mut self, input: &[u8]) -> bool { match sip_pa...
{ let _ = self.transactions.remove(idx); }
conditional_block
ntp.rs
/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
(&mut self, i: &[u8], _direction: u8) -> i32 { match parse_ntp(i) { Ok((_,ref msg)) => { // SCLogDebug!("parse_ntp: {:?}",msg); if msg.mode == NtpMode::SymmetricActive || msg.mode == NtpMode::Client { let mut tx = self.new_tx(); ...
parse
identifier_name
ntp.rs
/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
max_depth : 16, state_new : rs_ntp_state_new, state_free : rs_ntp_state_free, tx_free : rs_ntp_state_tx_free, parse_ts : rs_ntp_parse_request, parse_tc : rs_ntp_parse_response, get_tx_count : rs_ntp_st...
probe_ts : Some(ntp_probing_parser), probe_tc : Some(ntp_probing_parser), min_depth : 0,
random_line_split
ntp.rs
/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
/// Set an event. The event is set on the most recent transaction. pub fn set_event(&mut self, event: NTPEvent) { if let Some(tx) = self.transactions.last_mut() { tx.tx_data.set_event(event as u8); self.events += 1; } } } impl NTPTransaction { pub fn new(id: u6...
{ let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1); debug_assert!(tx != None); if let Some(idx) = tx { let _ = self.transactions.remove(idx); } }
identifier_body
ntp.rs
/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free * Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY...
, Err(_) => { return unsafe{ALPROTO_FAILED}; }, } } export_tx_data_get!(rs_ntp_get_tx_data, NTPTransaction); const PARSER_NAME : &'static [u8] = b"ntp\0"; #[no_mangle] pub unsafe extern "C" fn rs_register_ntp_parser() { let default_port = CString::new("123").unwrap(); let pars...
{ return ALPROTO_UNKNOWN; }
conditional_block
task-comm-13.rs
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except accordin...
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
random_line_split
task-comm-13.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ println!("Check that we don't deadlock."); let (tx, rx) = channel(); let _ = Thread::scoped(move|| { start(&tx, 0, 10) }).join(); println!("Joined task"); }
identifier_body
task-comm-13.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
() { println!("Check that we don't deadlock."); let (tx, rx) = channel(); let _ = Thread::scoped(move|| { start(&tx, 0, 10) }).join(); println!("Joined task"); }
main
identifier_name
tensor.rs
use std::ops::{Deref, DerefMut}; use enum_map::EnumMap; use crate::features::Layer; use tensorflow::{Tensor, TensorType}; /// Ad-hoc trait for shrinking batches. pub trait ShrinkBatch { fn shrink_batch(&self, n_instances: u64) -> Self; } impl<T> ShrinkBatch for Tensor<T> where T: Copy + TensorType, { fn...
let mut copy = Tensor::new(&new_shape); copy.copy_from_slice(&self[..new_shape.iter().cloned().product::<u64>() as usize]); copy } } impl<T> ShrinkBatch for TensorWrap<T> where T: Copy + TensorType, { fn shrink_batch(&self, n_instances: u64) -> Self { TensorWrap(self.0.shr...
let mut new_shape = self.dims().to_owned(); new_shape[0] = n_instances;
random_line_split
tensor.rs
use std::ops::{Deref, DerefMut}; use enum_map::EnumMap; use crate::features::Layer; use tensorflow::{Tensor, TensorType}; /// Ad-hoc trait for shrinking batches. pub trait ShrinkBatch { fn shrink_batch(&self, n_instances: u64) -> Self; } impl<T> ShrinkBatch for Tensor<T> where T: Copy + TensorType, { fn...
(&mut self, idx: usize) -> EnumMap<Layer, &mut [T]> { let mut slices = EnumMap::new(); for (layer, tensor) in self.iter_mut() { let layer_size = tensor.dims()[1] as usize; let offset = idx * layer_size; slices[layer] = &mut tensor[offset..offset + layer_size]; ...
to_instance_slices
identifier_name
tensor.rs
use std::ops::{Deref, DerefMut}; use enum_map::EnumMap; use crate::features::Layer; use tensorflow::{Tensor, TensorType}; /// Ad-hoc trait for shrinking batches. pub trait ShrinkBatch { fn shrink_batch(&self, n_instances: u64) -> Self; } impl<T> ShrinkBatch for Tensor<T> where T: Copy + TensorType, { fn...
} impl<T> Deref for TensorWrap<T> where T: TensorType, { type Target = Tensor<T>; fn deref(&self) -> &Self::Target { &self.0 } } impl<T> DerefMut for TensorWrap<T> where T: TensorType, { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } #[cfg(test)] mod test...
{ TensorWrap(tensor) }
identifier_body
coherence_copy_like_err_fundamental_struct_ref.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() {} } impl<T: lib::MyCopy> MyTrait for T { } // `MyFundamentalStruct` is declared fundamental, so we can test that // // MyFundamentalStruct<&MyTrait>:!MyTrait // // Huzzah. impl<'a> MyTrait for lib::MyFundamentalStruct<&'a MyType> { } fn main() { }
foo
identifier_name
coherence_copy_like_err_fundamental_struct_ref.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
extern crate coherence_copy_like_lib as lib; struct MyType { x: i32 } trait MyTrait { fn foo() {} } impl<T: lib::MyCopy> MyTrait for T { } // `MyFundamentalStruct` is declared fundamental, so we can test that // // MyFundamentalStruct<&MyTrait>:!MyTrait // // Huzzah. impl<'a> MyTrait for lib::MyFundamentalStruct...
random_line_split
coherence_copy_like_err_fundamental_struct_ref.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ }
identifier_body
model.rs
//! Defines the `JsonApiModel` trait. This is primarily used in conjunction with //! the [`jsonapi_model!`](../macro.jsonapi_model.html) macro to allow arbitrary //! structs which implement `Deserialize` to be converted to/from a //! [`JsonApiDocument`](../api/struct.JsonApiDocument.html) or //! [`Resource`](../api/str...
Some(IdentifierData::None) => Value::Null, Some(IdentifierData::Single(ref identifier)) => { let found = Self::lookup(identifier, inc) .map(|r| Self::resource_to_attrs(r, included, &this_visited) ); ...
random_line_split