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
compiler.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // 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 F...
match self.format { Format::ElementIsFolder | Format::DaysAreFolder | Format::MonthIsFolder => s.push_str(&format!("/{:02}", datetime.day())), Format::YearIsFolder => s.push_str(&format!("-{:02}",...
=> s.push_str(&format!("/{:02}", datetime.month())), } } if self.accuracy.has_day_accuracy() {
random_line_split
compiler.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // 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 F...
#[test] fn test_compiler_compile_month_accuracy() { let dt = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); test_accuracy(Accuracy::Month, dt, "module", "module/2000/01"); } #[test] fn test_compiler_compile_day_accuracy() { let dt = NaiveDate::from_ymd(2000, 1, 1).and_h...
{ let dt = NaiveDate::from_ymd(2000, 1, 1).and_hms(0, 0, 0); test_accuracy(Accuracy::Year, dt, "module", "module/2000"); }
identifier_body
lib.rs
// This file is part of the chessground library. // Copyright (C) 2017 Niklas Fiekas <niklas.fiekas@backscattering.de> // // This program is free software: you can redistribute it and/or modify
// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a ...
// it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
random_line_split
ipv4_header.rs
/* * Copyright (C) 2017 Genymobile * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed ...
(&self) -> Protocol { self.protocol } pub fn source(&self) -> u32 { self.source } pub fn destination(&self) -> u32 { self.destination } } pub fn peek_version_length(raw: &[u8]) -> Option<(u8, u16)> { if raw.len() >= 4 { // version is stored in the 4 first bits ...
protocol
identifier_name
ipv4_header.rs
/* * Copyright (C) 2017 Genymobile * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed ...
#[test] fn parse_header() { let raw = &create_header()[..]; let data = Ipv4HeaderData::parse(raw); assert_eq!(4, data.version); assert_eq!(20, data.header_length); assert_eq!(28, data.total_length); assert_eq!(Protocol::Udp, data.protocol); assert_eq!(0x...
{ let mut raw: Vec<u8> = Vec::new(); raw.reserve(20); raw.write_u8(4u8 << 4 | 5).unwrap(); // version_and_ihl raw.write_u8(0).unwrap(); //ToS raw.write_u16::<BigEndian>(28).unwrap(); // total length raw.write_u32::<BigEndian>(0).unwrap(); // id_flags_fragment_offset ...
identifier_body
ipv4_header.rs
/* * Copyright (C) 2017 Genymobile * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed ...
} pub fn peek_version_length(raw: &[u8]) -> Option<(u8, u16)> { if raw.len() >= 4 { // version is stored in the 4 first bits let version = raw[0] >> 4; // packet length is 16 bits starting at offset 2 let length = BigEndian::read_u16(&raw[2..4]); Some((version, length)) ...
pub fn destination(&self) -> u32 { self.destination }
random_line_split
main.rs
#[macro_use] extern crate lazy_static; extern crate image; extern crate chrono; extern crate regex; extern crate walkdir; use std::env; use std::error::Error; use std::fs; use std::io::prelude::*; use std::path::Path; use image::GenericImage; use chrono::prelude::*; use walkdir::WalkDir; use regex::Regex; /// initial...
} } } println!("DONE"); } else { help(); } } /// Output command line help fn help() { println!("usage: uploader <path to files> <path to output> <size>"); } /// Create a category directory (if it doesn't exist already) fn create_category_dir(category: &...
println!("created entry {:?}", &title);
random_line_split
main.rs
#[macro_use] extern crate lazy_static; extern crate image; extern crate chrono; extern crate regex; extern crate walkdir; use std::env; use std::error::Error; use std::fs; use std::io::prelude::*; use std::path::Path; use image::GenericImage; use chrono::prelude::*; use walkdir::WalkDir; use regex::Regex; /// initial...
{ let mut file = fs::File::open(&path).unwrap(); let input: Vec<u8> = Vec::new(); let content = String::from_utf8(input).unwrap(); let width = dimensions.0.to_string(); let height = dimensions.1.to_string(); let data = REPLACE_WIDTH.replace_all(&content, &width[..]); let data = REPLACE_HE...
identifier_body
main.rs
#[macro_use] extern crate lazy_static; extern crate image; extern crate chrono; extern crate regex; extern crate walkdir; use std::env; use std::error::Error; use std::fs; use std::io::prelude::*; use std::path::Path; use image::GenericImage; use chrono::prelude::*; use walkdir::WalkDir; use regex::Regex; /// initial...
(category: &str, base_path: &str) { let category_dir = format!("{}/{}", &base_path, &category); // create category dir if it doesn't exist already match fs::metadata(&category_dir) { Err(msg) => { if msg.description() == "entity not found" { println!("creating directory ...
create_category_dir
identifier_name
textdecoder.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::TextDecoderBinding; use crate::dom::bindings::codegen::Bindings::Tex...
in_stream: RefCell::new(Vec::new()), do_not_flush: Cell::new(false), } } fn make_range_error() -> Fallible<DomRoot<TextDecoder>> { Err(Error::Range( "The given encoding is not supported.".to_owned(), )) } pub fn new( global: &GlobalSc...
decoder: RefCell::new(if ignoreBOM { encoding.new_decoder() } else { encoding.new_decoder_without_bom_handling() }),
random_line_split
textdecoder.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::TextDecoderBinding; use crate::dom::bindings::codegen::Bindings::Tex...
self.in_stream.replace(Vec::new()); } // Step 2. self.do_not_flush.set(options.stream); // Step 3. match input { Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref a)) => { self.in_stream.borrow_mut().extend_from_slice(&a.to_vec()); ...
{ self.decoder.replace(self.encoding.new_decoder()); }
conditional_block
textdecoder.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::TextDecoderBinding; use crate::dom::bindings::codegen::Bindings::Tex...
Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref a)) => { self.in_stream.borrow_mut().extend_from_slice(&a.to_vec()); }, None => {}, }; let mut decoder = self.decoder.borrow_mut(); let (remaining, s) = { let mut in_stream = self....
{ // Step 1. if !self.do_not_flush.get() { if self.ignoreBOM { self.decoder .replace(self.encoding.new_decoder_without_bom_handling()); } else { self.decoder.replace(self.encoding.new_decoder()); } self.i...
identifier_body
textdecoder.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::TextDecoderBinding; use crate::dom::bindings::codegen::Bindings::Tex...
{ reflector_: Reflector, encoding: &'static Encoding, fatal: bool, ignoreBOM: bool, #[ignore_malloc_size_of = "defined in encoding_rs"] decoder: RefCell<Decoder>, in_stream: RefCell<Vec<u8>>, do_not_flush: Cell<bool>, } #[allow(non_snake_case)] impl TextDecoder { fn new_inherited(e...
TextDecoder
identifier_name
regions-trait-object-1.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...
fn extension<'e>(x: &'e E<'e>) -> Box<M+'e> { loop { let p = P { g: x.m() }; return Box::new(p) as Box<M+'e>; } } fn main() { let w = E { f: &10 }; let o = extension(&w); assert_eq!(o.n(), 10); }
} impl<'d> M for P<'d> { fn n(&self) -> u8 { *self.g } }
random_line_split
regions-trait-object-1.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...
} pub struct P<'c> { pub g: &'c u8, } pub trait M { fn n(&self) -> u8; } impl<'d> M for P<'d> { fn n(&self) -> u8 { *self.g } } fn extension<'e>(x: &'e E<'e>) -> Box<M+'e> { loop { let p = P { g: x.m() }; return Box::new(p) as Box<M+'e>; } } fn main() { let w = E { f: &10 }; ...
{ self.f }
identifier_body
regions-trait-object-1.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...
<'e>(x: &'e E<'e>) -> Box<M+'e> { loop { let p = P { g: x.m() }; return Box::new(p) as Box<M+'e>; } } fn main() { let w = E { f: &10 }; let o = extension(&w); assert_eq!(o.n(), 10); }
extension
identifier_name
git.rs
extern crate rpassword; use git2::{Config, Repository, BranchType}; use error::{Error, Result}; use url::Url; use std::path::Path; use std::env; #[derive(Debug, Copy, Clone, PartialEq)] pub enum GitMode { Create, Clone, Remote, Push, Rebase, } pub fn get_config_value(key: &str) -> Result<String> ...
let repo_path = Path::new(&repo_path); if!repo_path.exists() || (repo_path.is_dir() && repo_path.read_dir().unwrap().count() == 0) { let repo = try!(Repository::clone(repo_url, repo_path)); get_repo_dir(&repo) } else { Err(Error::InvalidTargetDir) } } fn find_repository(target...
{ let mut url = try!(Url::parse(repo_url)); try!(url.set_host(Some("localhost"))); let repo_path = target_dir.map(|x| x.to_string()).or_else(|| { match url.to_file_path() .ok() .map_or(None, |x| { x.file_stem() .map(|x| x.to_string_lossy()....
identifier_body
git.rs
extern crate rpassword; use git2::{Config, Repository, BranchType}; use error::{Error, Result}; use url::Url; use std::path::Path; use std::env; #[derive(Debug, Copy, Clone, PartialEq)] pub enum GitMode { Create, Clone, Remote, Push, Rebase, } pub fn get_config_value(key: &str) -> Result<String> ...
} let repo_path = repo_path.unwrap(); let repo_path = Path::new(&repo_path); if!repo_path.exists() || (repo_path.is_dir() && repo_path.read_dir().unwrap().count() == 0) { let repo = try!(Repository::clone(repo_url, repo_path)); get_repo_dir(&repo) } else { Err(Error::Invali...
if repo_path.is_none() { return Err(Error::InvalidTargetDir);
random_line_split
git.rs
extern crate rpassword; use git2::{Config, Repository, BranchType}; use error::{Error, Result}; use url::Url; use std::path::Path; use std::env; #[derive(Debug, Copy, Clone, PartialEq)] pub enum GitMode { Create, Clone, Remote, Push, Rebase, } pub fn get_config_value(key: &str) -> Result<String> ...
(target_dir: Option<&str>) -> Result<String> { let repo = try!(find_repository(target_dir)); let path = try!(repo.workdir().ok_or(Error::RepositoryBare)); path.file_name() .ok_or(Error::RepositoryBare) .map(|x| x.to_string_lossy().to_owned().to_string()) } fn set_upstream(repo: &mut Repositor...
get_repo_name
identifier_name
rtnl-route-event.rs
use std::io::Write; use std::mem::size_of; use std::ffi::CStr; extern crate libc; extern crate crslmnl as mnl; use libc::{ c_int, c_char, c_void, socklen_t }; use mnl::linux::netlink as netlink; use mnl::linux::rtnetlink; extern { // const char *inet_ntop(int af, const void *src, // cha...
}, _ => {}, } tb[atype as usize] = Some(attr); mnl::CbRet::OK } fn data_cb(nlh: mnl::Nlmsg, _: &mut Option<u8>) -> mnl::CbRet { let rm = nlh.payload::<rtnetlink::Rtmsg>(); match *nlh.nlmsg_type { n if n == rtnetlink::RTM_NEWROUTE => print!("[NEW] "), n if n == rtne...
{ println_stderr!("mnl_attr_validate - {}: {}", atype, errno); return mnl::CbRet::ERROR; }
conditional_block
rtnl-route-event.rs
use std::io::Write; use std::mem::size_of; use std::ffi::CStr; extern crate libc; extern crate crslmnl as mnl; use libc::{ c_int, c_char, c_void, socklen_t }; use mnl::linux::netlink as netlink; use mnl::linux::rtnetlink; extern { // const char *inet_ntop(int af, const void *src, // cha...
(nlh: mnl::Nlmsg, _: &mut Option<u8>) -> mnl::CbRet { let rm = nlh.payload::<rtnetlink::Rtmsg>(); match *nlh.nlmsg_type { n if n == rtnetlink::RTM_NEWROUTE => print!("[NEW] "), n if n == rtnetlink::RTM_DELROUTE => print!("[DEL] "), _ => {}, } // protocol family = AF_INET | AF_I...
data_cb
identifier_name
rtnl-route-event.rs
use std::io::Write; use std::mem::size_of; use std::ffi::CStr; extern crate libc; extern crate crslmnl as mnl; use libc::{ c_int, c_char, c_void, socklen_t }; use mnl::linux::netlink as netlink; use mnl::linux::rtnetlink; extern { // const char *inet_ntop(int af, const void *src, // cha...
// // ... user defined values... // // RT_SCOPE_SITE = 200 // RT_SCOPE_LINK = 253 : destination attached to link // RT_SCOPE_HOST = 254 : local address // RT_SCOPE_NOWHERE = 255 : not existing destination print!("scope={} ", rm.rtm_scope); // protocol: // RTPROT_UNSP...
// scope: // RT_SCOPE_UNIVERSE = 0 : everywhere in the universe
random_line_split
rtnl-route-event.rs
use std::io::Write; use std::mem::size_of; use std::ffi::CStr; extern crate libc; extern crate crslmnl as mnl; use libc::{ c_int, c_char, c_void, socklen_t }; use mnl::linux::netlink as netlink; use mnl::linux::rtnetlink; extern { // const char *inet_ntop(int af, const void *src, // cha...
macro_rules! println_stderr( ($($arg:tt)*) => { { let r = writeln!(&mut ::std::io::stderr(), $($arg)*); r.expect("failed printing to stderr"); } } ); fn data_attr_cb2<'a>(attr: &'a mnl::Attr, tb: &mut [Option<&'a mnl::Attr>]) -> mnl::CbRet { // skip unsupported attribute in user-space ...
{ let mut buf = [0u8; INET6_ADDRSTRLEN]; unsafe { let rs = inet_ntop(addr.family(), addr as *const _ as *const c_void, buf.as_mut_ptr() as *mut c_char, INET6_ADDRSTRLEN as socklen_t); CStr::from_ptr(rs).to_string_lossy().into_owned() } }
identifier_body
calendar.rs
// This file is part of rgtk. // // rgtk 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 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
mut self, day: u32) -> () { unsafe { ffi::gtk_calendar_mark_day(GTK_CALENDAR(self.pointer), day as c_uint) } } pub fn unmark_day(&mut self, day: u32) -> () { unsafe { ffi::gtk_calendar_unmark_day(GTK_CALENDAR(self.pointer), day as c_uint) } } pub...
rk_day(&
identifier_name
calendar.rs
// This file is part of rgtk. // // rgtk 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 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
pub fn set_detail_with_chars(&mut self, chars: i32) -> () { unsafe { ffi::gtk_calendar_set_detail_width_chars(GTK_CALENDAR(self.pointer), chars as c_int) } } pub fn get_detail_height_rows(&self) -> i32 { unsafe { ffi::gtk_calendar_get_detail_height_rows(GTK_C...
unsafe { ffi::gtk_calendar_get_detail_width_chars(GTK_CALENDAR(self.pointer)) } }
identifier_body
calendar.rs
// This file is part of rgtk. // // rgtk 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 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
impl_drop!(Calendar) impl_TraitWidget!(Calendar) impl_widget_events!(Calendar)
random_line_split
qobject_test.rs
extern crate qmlrs; extern crate libc; use qmlrs::*; #[test] pub fn
() { let mut engine = qmlrs::Engine::new("test"); extern "C" fn test_slot(_: *mut ffi::QObject, id: libc::c_int, _: *const ffi::QVariantList, ret: *mut ffi::QVariant) { println!("slot: {} called",id); if 1 == id { println!("test_slot called"); } else if 2 == id { ...
qobject_test
identifier_name
qobject_test.rs
extern crate qmlrs; extern crate libc; use qmlrs::*; #[test] pub fn qobject_test() { let mut engine = qmlrs::Engine::new("test"); extern "C" fn test_slot(_: *mut ffi::QObject, id: libc::c_int, _: *const ffi::QVariantList, ret: *mut ffi::QVariant) { println!("slot: {} called",id); if 1 == id...
else { panic!("unknown id {}",id); } } let mut metaobj = MetaObject::new("Person",test_slot); assert_eq!(metaobj.add_signal("nameChanged()"),0); metaobj.add_property("name","QString",Some("nameChanged()")); assert_eq!(metaobj.add_slot("test_slot()"),1); assert_eq!(metaobj...
{ println!("func(int) called"); unsafe { ffi::qmlrs_variant_set_int64(ret,42); } }
conditional_block
qobject_test.rs
extern crate qmlrs; extern crate libc; use qmlrs::*; #[test] pub fn qobject_test()
assert_eq!(metaobj.add_signal("nameChanged()"),0); metaobj.add_property("name","QString",Some("nameChanged()")); assert_eq!(metaobj.add_slot("test_slot()"),1); assert_eq!(metaobj.add_method("func(QVariant)","int"),2); let mut obj = metaobj.instantiate(); obj.set_property("name",Variant::S...
{ let mut engine = qmlrs::Engine::new("test"); extern "C" fn test_slot(_: *mut ffi::QObject, id: libc::c_int, _: *const ffi::QVariantList, ret: *mut ffi::QVariant) { println!("slot: {} called",id); if 1 == id { println!("test_slot called"); } else if 2 == id { p...
identifier_body
qobject_test.rs
extern crate qmlrs; extern crate libc; use qmlrs::*; #[test] pub fn qobject_test() { let mut engine = qmlrs::Engine::new("test"); extern "C" fn test_slot(_: *mut ffi::QObject, id: libc::c_int, _: *const ffi::QVariantList, ret: *mut ffi::QVariant) { println!("slot: {} called",id); if 1 == id...
} } else { panic!("unknown id {}",id); } } let mut metaobj = MetaObject::new("Person",test_slot); assert_eq!(metaobj.add_signal("nameChanged()"),0); metaobj.add_property("name","QString",Some("nameChanged()")); assert_eq!(metaobj.add_slot("test_slot()"),1);...
ffi::qmlrs_variant_set_int64(ret,42);
random_line_split
on-trait.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 ...
pub fn main() { let x = vec![1u8, 2, 3, 4]; let y: Option<Vec<u8>> = collect(x.iter()); // this should give approximately the same error for x.iter().collect() //~^ ERROR let x: String = foobar(); //~ ERROR }
{ MyFromIterator::my_from_iter(it) }
identifier_body
on-trait.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 ...
<A, I: Iterator<Item=A>, B: MyFromIterator<A>>(it: I) -> B { MyFromIterator::my_from_iter(it) } pub fn main() { let x = vec![1u8, 2, 3, 4]; let y: Option<Vec<u8>> = collect(x.iter()); // this should give approximately the same error for x.iter().collect() //~^ ERROR let x: String = foobar(); //~ E...
collect
identifier_name
on-trait.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. //
// ignore-tidy-linelength #![feature(on_unimplemented)] pub mod Bar { #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{Foo}`"] pub trait Foo<Bar, Baz, Quux> {} } use Bar::Foo; fn foobar<U: Clone, T: Foo<u8, U, u32>>() -> T { panic!() } #[rustc_on_unimplemented="a collectio...
// 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 according to those terms.
random_line_split
mod.rs
mod component; mod node; mod transform; mod model; mod camera; use common::*; use renderer::Renderer; use renderer::geometry::Geometry; use renderer::IndexType; use renderer::util::mesh::{load_meshes_from_file, MeshData, MeshOptions}; pub use self::node::{Node, NodeRef, WeakNodeRef}; pub use self::component::SceneCom...
} } pub fn camera_mut(&mut self) -> &mut Camera { &mut self.camera } pub fn new_child_node(&mut self, name: &str) -> NodeRef { let child = Node::new(name, Some(Rc::downgrade(&self.root_node))); self.root_node.borrow_mut().attach_child(child) } pub f...
root_node: Rc::new(RefCell::new(Node::new("_root", None))), camera: Camera::new(deg(45f32), aspect, 0.1f32, 1000f32),
random_line_split
mod.rs
mod component; mod node; mod transform; mod model; mod camera; use common::*; use renderer::Renderer; use renderer::geometry::Geometry; use renderer::IndexType; use renderer::util::mesh::{load_meshes_from_file, MeshData, MeshOptions}; pub use self::node::{Node, NodeRef, WeakNodeRef}; pub use self::component::SceneCom...
pub fn attach_model_component_from_file(&mut self, node: &NodeRef, path: &Path) { let mut geometries: Vec<Box<Geometry>> = Vec::new(); let mesh_data: Vec<MeshData> = load_meshes_from_file(path, &MeshOptions::default()).unwrap(); // this lameness will have to suffice until a p...
{ let child = Node::new(name, Some(Rc::downgrade(&self.root_node))); self.root_node.borrow_mut().attach_child(child) }
identifier_body
mod.rs
mod component; mod node; mod transform; mod model; mod camera; use common::*; use renderer::Renderer; use renderer::geometry::Geometry; use renderer::IndexType; use renderer::util::mesh::{load_meshes_from_file, MeshData, MeshOptions}; pub use self::node::{Node, NodeRef, WeakNodeRef}; pub use self::component::SceneCom...
(renderer: Box<Renderer>, aspect: f32) -> Scene { Scene { renderer: renderer, root_node: Rc::new(RefCell::new(Node::new("_root", None))), camera: Camera::new(deg(45f32), aspect, 0.1f32, 1000f32), } } pub fn camera_mut(&mut self) -> &mut Camera { &...
new
identifier_name
mod.rs
pub mod types; pub mod utils; use crate::metrics::SizeStats; use crate::error::*; use std::sync::Arc; use parking_lot::RwLock; use std::ops::{ DerefMut, Deref }; use bytes::BytesMut; use redis_protocol::encode::encode_bytes; use redis_protocol::decode::decode_bytes; use redis_protocol::types::Frame as Protocol...
let (frame, amt) = decode_bytes(buf)?; if let Some(frame) = frame { trace!("{} Parsed {} bytes.", self.name, amt); buf.split_to(amt); self.res_size_stats.write().deref_mut().sample(amt as u64); Ok(Some(utils::check_auth_error(frame))) }else{ Ok(None) } } } impl Enc...
{ return Ok(None); }
conditional_block
mod.rs
pub mod types; pub mod utils; use crate::metrics::SizeStats; use crate::error::*; use std::sync::Arc; use parking_lot::RwLock; use std::ops::{ DerefMut, Deref }; use bytes::BytesMut; use redis_protocol::encode::encode_bytes; use redis_protocol::decode::decode_bytes; use redis_protocol::types::Frame as Protocol...
(name: String, req_size_stats: Arc<RwLock<SizeStats>>, res_size_stats: Arc<RwLock<SizeStats>>) -> Self { RedisCodec { name, req_size_stats, res_size_stats } } } impl Decoder for RedisCodec { type Item = ProtocolFrame; type Error = RedisError; fn decode(&mut self, buf: &mut BytesMut)...
new
identifier_name
mod.rs
pub mod types; pub mod utils; use crate::metrics::SizeStats; use crate::error::*; use std::sync::Arc; use parking_lot::RwLock; use std::ops::{ DerefMut, Deref }; use bytes::BytesMut; use redis_protocol::encode::encode_bytes; use redis_protocol::decode::decode_bytes; use redis_protocol::types::Frame as Protocol...
} impl Encoder for RedisCodec { type Item = ProtocolFrame; type Error = RedisError; fn encode(&mut self, frame: ProtocolFrame, buf: &mut BytesMut) -> Result<(), RedisError> { let offset = buf.len(); let res = encode_bytes(buf, &frame)?; let len = res.saturating_sub(offset); trace!("{} Encode...
{ trace!("{} Recv {} bytes.", self.name, buf.len()); if buf.len() < 1 { return Ok(None); } let (frame, amt) = decode_bytes(buf)?; if let Some(frame) = frame { trace!("{} Parsed {} bytes.", self.name, amt); buf.split_to(amt); self.res_size_stats.write().deref_mut().sample(...
identifier_body
mod.rs
pub mod types; pub mod utils; use crate::metrics::SizeStats; use crate::error::*; use std::sync::Arc; use parking_lot::RwLock; use std::ops::{ DerefMut, Deref }; use bytes::BytesMut; use redis_protocol::encode::encode_bytes; use redis_protocol::decode::decode_bytes; use redis_protocol::types::Frame as ProtocolF...
} }
self.req_size_stats.write().deref_mut().sample(len as u64); Ok(())
random_line_split
liveness.rs
// Copyright 2012 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 ...
(proto: protocol, _cx: @ext_ctxt) { debug!("initializing colive analysis"); let num_states = proto.num_states(); let mut colive = do (copy proto.states).map_to_vec |state| { let mut bv = ~Bitv::new(num_states, false); for state.reachable |s| { bv.set(s.id, true); } ...
analyze
identifier_name
liveness.rs
// Copyright 2012 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 ...
optimizations. This analysis computes the "co-live" relationship between states. Co-live is defined inductively as follows. 1. u is co-live with v if u can transition to v in one message. 2. u is co-live with v if there exists a w such that u and w are co-live, w and v are co-live, and u and w have the same directio...
Liveness analysis for protocols. This is useful for a lot of possible
random_line_split
liveness.rs
// Copyright 2012 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 ...
for this_colive.ones |j| { let next = proto.get_state_by_id(j); if this.dir == next.dir { changed = result.union(colive[j]) || changed; } } new_colive.push(result) } colive = new_colive; i += ...
{ debug!("initializing colive analysis"); let num_states = proto.num_states(); let mut colive = do (copy proto.states).map_to_vec |state| { let mut bv = ~Bitv::new(num_states, false); for state.reachable |s| { bv.set(s.id, true); } bv }; let mut i = 0; ...
identifier_body
liveness.rs
// Copyright 2012 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 ...
} if self_live.len() > 0 { let states = str::connect(self_live.map(|s| copy s.name), ~" "); debug!("protocol %s is unbounded due to loops involving: %s", copy proto.name, states); // Someday this will be configurable with a warning //cx.span_warn(empty_span(), ...
{ self_live.push(proto.get_state_by_id(i)) }
conditional_block
main.rs
use std::env; use std::io::Read; use std::net::*; use std::sync::atomic::*; use std::thread; use std::time::Duration; static AMT: AtomicUsize = ATOMIC_USIZE_INIT; fn
() { thread::spawn(|| { loop { thread::sleep(Duration::new(1, 0)); println!("{}", AMT.swap(0, Ordering::SeqCst)); } }); let addr = env::args().nth(1).unwrap_or("127.0.0.1:12345".to_string()); let addr = addr.parse::<SocketAddr>().unwrap(); let mut c = TcpStre...
main
identifier_name
main.rs
use std::env; use std::io::Read; use std::net::*; use std::sync::atomic::*; use std::thread; use std::time::Duration; static AMT: AtomicUsize = ATOMIC_USIZE_INIT; fn main() { thread::spawn(|| { loop { thread::sleep(Duration::new(1, 0)); println!("{}", AMT.swap(0, Ordering::SeqCst))...
} } }
{ AMT.fetch_add(n, Ordering::SeqCst); }
conditional_block
main.rs
use std::env; use std::io::Read; use std::net::*; use std::sync::atomic::*; use std::thread; use std::time::Duration; static AMT: AtomicUsize = ATOMIC_USIZE_INIT; fn main()
{ thread::spawn(|| { loop { thread::sleep(Duration::new(1, 0)); println!("{}", AMT.swap(0, Ordering::SeqCst)); } }); let addr = env::args().nth(1).unwrap_or("127.0.0.1:12345".to_string()); let addr = addr.parse::<SocketAddr>().unwrap(); let mut c = TcpStream:...
identifier_body
main.rs
use std::env; use std::io::Read; use std::net::*; use std::sync::atomic::*; use std::thread; use std::time::Duration; static AMT: AtomicUsize = ATOMIC_USIZE_INIT; fn main() {
loop { thread::sleep(Duration::new(1, 0)); println!("{}", AMT.swap(0, Ordering::SeqCst)); } }); let addr = env::args().nth(1).unwrap_or("127.0.0.1:12345".to_string()); let addr = addr.parse::<SocketAddr>().unwrap(); let mut c = TcpStream::connect(&addr).unwrap();...
thread::spawn(|| {
random_line_split
tag.rs
// Copyright 2012 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 f() { let x = red(1, 2); let y = green; assert!((x!= y)); } pub fn main() { f(); }
{ !(*self).eq(other) }
identifier_body
tag.rs
// Copyright 2012 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 ...
match *self { red(a0, b0) => { match (*other) { red(a1, b1) => a0 == a1 && b0 == b1, green => false, } } green => { match (*other) { red(..) => false, ...
impl Eq for colour { fn eq(&self, other: &colour) -> bool {
random_line_split
tag.rs
// Copyright 2012 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 ...
(&self, other: &colour) -> bool { match *self { red(a0, b0) => { match (*other) { red(a1, b1) => a0 == a1 && b0 == b1, green => false, } } green => { match (*other) { r...
eq
identifier_name
color_chooser.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use ffi; use gdk; use gdk_ffi; use glib; use glib::object::Downcast; use glib::object::IsA; use glib::signal::connect; use glib::translate::*; use glib_ffi; use std::boxed::Box as Box_; use std::mem::transmute; glib_wrapper! { pub...
fn connect_color_activated<F: Fn(&Self, &gdk::RGBA) +'static>(&self, f: F) -> u64 { unsafe { let f: Box_<Box_<Fn(&Self, &gdk::RGBA) +'static>> = Box_::new(Box_::new(f)); connect(self.to_glib_none().0, "color-activated", transmute(color_activated_trampoline::<Self> a...
{ unsafe { ffi::gtk_color_chooser_set_use_alpha(self.to_glib_none().0, use_alpha.to_glib()); } }
identifier_body
color_chooser.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use ffi; use gdk; use gdk_ffi; use glib; use glib::object::Downcast; use glib::object::IsA; use glib::signal::connect; use glib::translate::*; use glib_ffi; use std::boxed::Box as Box_; use std::mem::transmute; glib_wrapper! { pub...
unsafe extern "C" fn color_activated_trampoline<P>(this: *mut ffi::GtkColorChooser, color: *mut gdk_ffi::GdkRGBA, f: glib_ffi::gpointer) where P: IsA<ColorChooser> { callback_guard!(); let f: &Box_<Fn(&P, &gdk::RGBA) +'static> = transmute(f); f(&ColorChooser::from_glib_none(this).downcast_unchecked(), &fro...
random_line_split
color_chooser.rs
// This file was generated by gir (5c017c9) from gir-files (71d73f0) // DO NOT EDIT use ffi; use gdk; use gdk_ffi; use glib; use glib::object::Downcast; use glib::object::IsA; use glib::signal::connect; use glib::translate::*; use glib_ffi; use std::boxed::Box as Box_; use std::mem::transmute; glib_wrapper! { pub...
<P>(this: *mut ffi::GtkColorChooser, color: *mut gdk_ffi::GdkRGBA, f: glib_ffi::gpointer) where P: IsA<ColorChooser> { callback_guard!(); let f: &Box_<Fn(&P, &gdk::RGBA) +'static> = transmute(f); f(&ColorChooser::from_glib_none(this).downcast_unchecked(), &from_glib_none(color)) }
color_activated_trampoline
identifier_name
cursor.rs
use bson::{Bson, Document}; use mongodb::{Client, CommandType, ThreadedClient}; use mongodb::common::{ReadMode, ReadPreference}; use mongodb::db::ThreadedDatabase; use mongodb::cursor::Cursor; use mongodb::wire_protocol::flags::OpQueryFlags; #[test] fn
() { let client = Client::connect("localhost", 27017).unwrap(); let db = client.db("test"); let coll = db.collection("cursor_test"); coll.drop().ok().expect("Failed to drop database."); let docs = (0..10).map(|i| { doc! { "foo" => (i as i64) } }).collect(); assert!(coll.insert_man...
cursor_features
identifier_name
cursor.rs
use bson::{Bson, Document}; use mongodb::{Client, CommandType, ThreadedClient}; use mongodb::common::{ReadMode, ReadPreference}; use mongodb::db::ThreadedDatabase; use mongodb::cursor::Cursor; use mongodb::wire_protocol::flags::OpQueryFlags; #[test] fn cursor_features()
let mut cursor = match result { Ok(c) => c, Err(s) => panic!("{}", s) }; let batch = cursor.next_batch().ok().expect("Failed to get next batch from cursor."); assert_eq!(batch.len(), 3 as usize); for i in 0..batch.len() { match batch[i].get("foo") { Some(&Bson:...
{ let client = Client::connect("localhost", 27017).unwrap(); let db = client.db("test"); let coll = db.collection("cursor_test"); coll.drop().ok().expect("Failed to drop database."); let docs = (0..10).map(|i| { doc! { "foo" => (i as i64) } }).collect(); assert!(coll.insert_many(d...
identifier_body
cursor.rs
use bson::{Bson, Document}; use mongodb::{Client, CommandType, ThreadedClient}; use mongodb::common::{ReadMode, ReadPreference}; use mongodb::db::ThreadedDatabase;
#[test] fn cursor_features() { let client = Client::connect("localhost", 27017).unwrap(); let db = client.db("test"); let coll = db.collection("cursor_test"); coll.drop().ok().expect("Failed to drop database."); let docs = (0..10).map(|i| { doc! { "foo" => (i as i64) } }).collect(); ...
use mongodb::cursor::Cursor; use mongodb::wire_protocol::flags::OpQueryFlags;
random_line_split
panic_info.rs
use crate::any::Any; use crate::fmt; use crate::panic::Location; /// A struct providing information about a panic. /// /// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`] /// function. /// /// [`set_hook`]:../../std/panic/fn.set_hook.html /// /// # Examples /// /// ```should_panic /// use std::...
// NOTE: we cannot use downcast_ref::<String>() here // since String is not available in libcore! // The payload is a String when `std::panic!` is called with multiple arguments, // but in that case the message is also available. self.location.fmt(formatter) } }
{ write!(formatter, "'{}', ", payload)? }
conditional_block
panic_info.rs
use crate::any::Any; use crate::fmt; use crate::panic::Location; /// A struct providing information about a panic. /// /// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`] /// function. /// /// [`set_hook`]:../../std/panic/fn.set_hook.html /// /// # Examples /// /// ```should_panic /// use std::...
(&mut self, info: &'a (dyn Any + Send)) { self.payload = info; } /// Returns the payload associated with the panic. /// /// This will commonly, but not always, be a `&'static str` or [`String`]. /// /// [`String`]:../../std/string/struct.String.html /// /// # Examples /// ...
set_payload
identifier_name
panic_info.rs
use crate::any::Any; use crate::fmt; use crate::panic::Location; /// A struct providing information about a panic. /// /// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`] /// function. /// /// [`set_hook`]:../../std/panic/fn.set_hook.html /// /// # Examples /// /// ```should_panic /// use std::...
/// If the `panic!` macro from the `core` crate (not from `std`) /// was used with a formatting string and some additional arguments, /// returns that message ready to be used for example with [`fmt::write`] #[unstable(feature = "panic_info_message", issue = "66745")] pub fn message(&self) -> Opti...
{ self.payload }
identifier_body
panic_info.rs
use crate::any::Any; use crate::fmt;
/// A struct providing information about a panic. /// /// `PanicInfo` structure is passed to a panic hook set by the [`set_hook`] /// function. /// /// [`set_hook`]:../../std/panic/fn.set_hook.html /// /// # Examples /// /// ```should_panic /// use std::panic; /// /// panic::set_hook(Box::new(|panic_info| { /// if ...
use crate::panic::Location;
random_line_split
multiwindow.rs
#[cfg(target_os = "android")] #[macro_use] extern crate android_glue; extern crate glutin; use std::thread; mod support; #[cfg(target_os = "android")] android_start!(main); #[cfg(not(feature = "window"))] fn main() { println!("This example requires glutin to be compiled with the `window` feature"); } #[cfg(featur...
{ unsafe { window.make_current() }; let context = support::load(&window); while !window.is_closed() { context.draw_frame(color); window.swap_buffers(); window.wait_events().next(); } }
identifier_body
multiwindow.rs
#[cfg(target_os = "android")] #[macro_use] extern crate android_glue; extern crate glutin; use std::thread; mod support; #[cfg(target_os = "android")] android_start!(main); #[cfg(not(feature = "window"))] fn main() { println!("This example requires glutin to be compiled with the `window` feature"); } #[cfg(featur...
window.wait_events().next(); } }
random_line_split
multiwindow.rs
#[cfg(target_os = "android")] #[macro_use] extern crate android_glue; extern crate glutin; use std::thread; mod support; #[cfg(target_os = "android")] android_start!(main); #[cfg(not(feature = "window"))] fn
() { println!("This example requires glutin to be compiled with the `window` feature"); } #[cfg(feature = "window")] fn main() { let window1 = glutin::Window::new().unwrap(); let window2 = glutin::Window::new().unwrap(); let window3 = glutin::Window::new().unwrap(); let t1 = thread::spawn(move || { ...
main
identifier_name
copy-object.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. #...
if name == None { new_name = key.clone(); } else { new_name = name.unwrap(); } if verbose { println!("S3 client version: {}", PKG_VERSION); println!( "Region: {}", region_provider.region().await.unwrap().as_ref() ); pr...
{ tracing_subscriber::fmt::init(); let Opt { region, source, destination, key, name, verbose, } = Opt::from_args(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() .or_else(Region::new(...
identifier_body
copy-object.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. #...
() -> Result<(), Error> { tracing_subscriber::fmt::init(); let Opt { region, source, destination, key, name, verbose, } = Opt::from_args(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() ...
main
identifier_name
copy-object.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. #...
if verbose { println!("S3 client version: {}", PKG_VERSION); println!( "Region: {}", region_provider.region().await.unwrap().as_ref() ); println!("Source bucket: {}", &source); println!("Source key: {}", &key); print...
{ new_name = name.unwrap(); }
conditional_block
copy-object.rs
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{Client, Error, Region, PKG_VERSION}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// The AWS Region. #...
} // snippet-end:[bin.rust.copy-object] /// Copies an object from one Amazon S3 bucket to another. /// # Arguments /// /// * `-s SOURCE` - The name of the source bucket. /// * `-d DESTINATION` - The name of the destination bucket. /// * `-k KEY` - The name of the object to copy. /// * `-n NAME` - The new name of the o...
Ok(())
random_line_split
get_pushrule_enabled.rs
//! [GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-pushrules-scope-kind-ruleid-enabled) use ruma_api::ruma_api; use super::RuleKind; ruma_api! { metadata { description: "This endpoint gets whether the specified pus...
#[ruma_api(path)] pub kind: RuleKind, /// The identifier for the rule. #[ruma_api(path)] pub rule_id: String, } response { /// Whether the push rule is enabled or not. pub enabled: bool } error: crate::Error }
/// The scope to fetch a rule from. 'global' to specify global rules. #[ruma_api(path)] pub scope: String, /// The kind of rule
random_line_split
main.rs
extern crate ws; extern crate clap; extern crate serde; extern crate serde_json; use serde_json::Value; use serde_json::value::Map; use clap::{App, Arg}; struct BenchHandler { ws: ws::Sender, count: u32 } impl ws::Handler for BenchHandler { fn on_message(&mut self, msg: ws::Message) -> ws::Result<()> {...
Ok(()) } fn on_open(&mut self, _: ws::Handshake) -> ws::Result<()> { self.count += 1; println!("Connection Open! {}", self.count); Ok(()) } fn on_close(&mut self,_: ws::CloseCode, _: &str) { self.count -= 1; println!("Connection Closed! {}", self.count)...
{ if let Some((Some(msg_type), payload)) = serde_json::from_str(body.as_str()).ok() .and_then(|j: Value| j.as_object().map(move |obj: &Map<String, Value>| { let t = obj.get("type").and_then(|t| t.as_str()).map(|s| s.to_owned()); let p: Value = obj.get(...
conditional_block
main.rs
extern crate ws; extern crate clap; extern crate serde; extern crate serde_json; use serde_json::Value; use serde_json::value::Map; use clap::{App, Arg}; struct BenchHandler { ws: ws::Sender, count: u32 } impl ws::Handler for BenchHandler { fn
(&mut self, msg: ws::Message) -> ws::Result<()> { if let Ok(body) = msg.into_text() { if let Some((Some(msg_type), payload)) = serde_json::from_str(body.as_str()).ok() .and_then(|j: Value| j.as_object().map(move |obj: &Map<String, Value>| { let t = obj.get("type")....
on_message
identifier_name
main.rs
extern crate ws; extern crate clap; extern crate serde; extern crate serde_json; use serde_json::Value; use serde_json::value::Map; use clap::{App, Arg}; struct BenchHandler { ws: ws::Sender, count: u32 } impl ws::Handler for BenchHandler { fn on_message(&mut self, msg: ws::Message) -> ws::Result<()> {...
})) { match msg_type.as_ref() { "echo" => { try!(self.ws.send(body.as_str())); }, "broadcast" => { try!(self.ws.broadcast(body.as_str())); try!(self.ws.send...
random_line_split
cci_nested_exe.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:cci_nested_lib.rs // pretty-expanded FIXME #23616 #![feature(globs)] extern crate cci_nested_lib; use cci_nested_lib::*; pub fn main() { ...
// 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
random_line_split
cci_nested_exe.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...
{ let lst = new_int_alist(); alist_add(&lst, 22, "hi".to_string()); alist_add(&lst, 44, "ho".to_string()); assert_eq!(alist_get(&lst, 22), "hi".to_string()); assert_eq!(alist_get(&lst, 44), "ho".to_string()); let lst = new_int_alist_2(); alist_add(&lst, 22, "hi".to_string()); alist_add(...
identifier_body
cci_nested_exe.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...
() { let lst = new_int_alist(); alist_add(&lst, 22, "hi".to_string()); alist_add(&lst, 44, "ho".to_string()); assert_eq!(alist_get(&lst, 22), "hi".to_string()); assert_eq!(alist_get(&lst, 44), "ho".to_string()); let lst = new_int_alist_2(); alist_add(&lst, 22, "hi".to_string()); alist_a...
main
identifier_name
ram.rs
use std::cmp; use std::sync; use super::super::*; pub struct RAM { pub storage: sync::RwLock<Vec<u8>>, } impl RAM { pub fn with_capacity(capacity: usize) -> RAM { RAM { storage: sync::RwLock::new(vec![0u8; capacity]), } } } impl super::Memory for RAM { fn read(&self, addr...
fn write(&self, addr: u64, src: &[u8]) -> Result<()> { let mut storage = match self.storage.write() { Ok(x) => x, _ => { return Err(Error::Unknown(format!("failed to write to RAM"))) }, }; let addr = addr as usize; let mem_size = storage.len(); ...
Err(Error::Unknown(format!("tried to read invalid RAM address 0x{:x}", addr))) } }
random_line_split
ram.rs
use std::cmp; use std::sync; use super::super::*; pub struct RAM { pub storage: sync::RwLock<Vec<u8>>, } impl RAM { pub fn
(capacity: usize) -> RAM { RAM { storage: sync::RwLock::new(vec![0u8; capacity]), } } } impl super::Memory for RAM { fn read(&self, addr: u64, dest: &mut [u8]) -> Result<()> { let storage = match self.storage.read() { Ok(x) => x, _ => { return Err(Err...
with_capacity
identifier_name
ram.rs
use std::cmp; use std::sync; use super::super::*; pub struct RAM { pub storage: sync::RwLock<Vec<u8>>, } impl RAM { pub fn with_capacity(capacity: usize) -> RAM { RAM { storage: sync::RwLock::new(vec![0u8; capacity]), } } } impl super::Memory for RAM { fn read(&self, addr...
} }
{ Err(Error::Unknown(format!("tried to write invalid RAM address 0x{:x}", addr))) }
conditional_block
main.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of...
#[link(name="glfw")] extern {} fn main() { println(glfw::get_version().to_str()); println!("GLFW version: {:s}", glfw::get_version_string()); }
extern mod glfw;
random_line_split
main.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of...
{ println(glfw::get_version().to_str()); println!("GLFW version: {:s}", glfw::get_version_string()); }
identifier_body
main.rs
// Copyright 2013 The GLFW-RS Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of...
() { println(glfw::get_version().to_str()); println!("GLFW version: {:s}", glfw::get_version_string()); }
main
identifier_name
sts.rs
#[doc = "Register `STS` reader"] pub struct R(crate::R<STS_SPEC>); impl core::ops::Deref for R { type Target = crate::R<STS_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<STS_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<STS_SPEC>) ...
{ #[doc = "0: no write error occurred."] VALUE1 = 0, #[doc = "1: write error occurred, interrupt request is pending."] VALUE2 = 1, } impl From<WERR_A> for bool { #[inline(always)] fn from(variant: WERR_A) -> Self { variant as u8!= 0 } } #[doc = "Field `WERR` reader - Bufferable Writ...
WERR_A
identifier_name
sts.rs
#[doc = "Register `STS` reader"] pub struct R(crate::R<STS_SPEC>); impl core::ops::Deref for R { type Target = crate::R<STS_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<STS_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<STS_SPEC>) ...
#[doc = "Checks if the value of the field is `VALUE1`"] #[inline(always)] pub fn is_value1(&self) -> bool { **self == WERR_A::VALUE1 } #[doc = "Checks if the value of the field is `VALUE2`"] #[inline(always)] pub fn is_value2(&self) -> bool { **self == WERR_A::VALUE2 } }...
{ match self.bits { false => WERR_A::VALUE1, true => WERR_A::VALUE2, } }
identifier_body
sts.rs
#[doc = "Register `STS` reader"] pub struct R(crate::R<STS_SPEC>); impl core::ops::Deref for R { type Target = crate::R<STS_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<STS_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<STS_SPEC>) ...
#[doc = "Checks if the value of the field is `VALUE1`"] #[inline(always)] pub fn is_value1(&self) -> bool { **self == WERR_A::VALUE1 } #[doc = "Checks if the value of the field is `VALUE2`"] #[inline(always)] pub fn is_value2(&self) -> bool { **self == WERR_A::VALUE2 } } ...
} }
random_line_split
edgeop.rs
use graph_edge_evolution::{EdgeOperation, GraphBuilder, NthEdgeF}; use triadic_census::OptDenseDigraph; use std::collections::BTreeMap; use asexp::Sexp; defops!{EdgeOp; Dup, Split, Loop, Merge, Next, Parent, Reverse, Save, Restore, Output, SetEdgeWeight, IncEdgeWeight, ...
(edgeops: &[(EdgeOp, f32)]) -> OptDenseDigraph<f32, f32> { let mut builder: GraphBuilder<f32, f32> = GraphBuilder::new(); for &(op, f) in edgeops { let graph_op = match op { EdgeOp::Dup => EdgeOperation::Duplicate { weight: f }, EdgeOp::Split => EdgeOperation::Split { weight: f }...
edgeops_to_graph
identifier_name
edgeop.rs
use graph_edge_evolution::{EdgeOperation, GraphBuilder, NthEdgeF}; use triadic_census::OptDenseDigraph; use std::collections::BTreeMap; use asexp::Sexp; defops!{EdgeOp; Dup, Split, Loop, Merge, Next, Parent, Reverse, Save, Restore, Output, SetEdgeWeight, IncEdgeWeight, ...
} pub fn edgeops_to_graph(edgeops: &[(EdgeOp, f32)]) -> OptDenseDigraph<f32, f32> { let mut builder: GraphBuilder<f32, f32> = GraphBuilder::new(); for &(op, f) in edgeops { let graph_op = match op { EdgeOp::Dup => EdgeOperation::Duplicate { weight: f }, EdgeOp::Split => EdgeOpe...
{ Sexp::from(self.to_string()) }
identifier_body
edgeop.rs
use graph_edge_evolution::{EdgeOperation, GraphBuilder, NthEdgeF}; use triadic_census::OptDenseDigraph; use std::collections::BTreeMap; use asexp::Sexp; defops!{EdgeOp; Dup, Split, Loop, Merge, Next, Parent, Reverse, Save, Restore, Output,
SetNodeWeight, IncNodeWeight, DecNodeWeight } impl Into<Sexp> for EdgeOp { fn into(self) -> Sexp { Sexp::from(self.to_string()) } } pub fn edgeops_to_graph(edgeops: &[(EdgeOp, f32)]) -> OptDenseDigraph<f32, f32> { let mut builder: GraphBuilder<f32, f32> = GraphBuilder::new(); for &...
SetEdgeWeight, IncEdgeWeight, DecEdgeWeight,
random_line_split
issue22656.rs
// Copyright 2013-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-MI...
fn zzz() { () }
{ let v = vec![1,2,3]; let zs = StructWithZeroSizedField { x: ZeroSizedStruct, y: 123, z: ZeroSizedStruct, w: 456 }; zzz(); // #break }
identifier_body
issue22656.rs
// Copyright 2013-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-MI...
{ x: ZeroSizedStruct, y: u32, z: ZeroSizedStruct, w: u64 } fn main() { let v = vec![1,2,3]; let zs = StructWithZeroSizedField { x: ZeroSizedStruct, y: 123, z: ZeroSizedStruct, w: 456 }; zzz(); // #break } fn zzz() { () }
StructWithZeroSizedField
identifier_name
issue22656.rs
// Copyright 2013-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-MI...
}; zzz(); // #break } fn zzz() { () }
z: ZeroSizedStruct, w: 456
random_line_split
main.rs
extern crate git2; use std::cell::RefCell; use std::collections::HashMap; use std::env::args; use std::path::Path; use git2::{Branch, BranchType, Commit, ResetType, ObjectType, Oid, Repository, Signature, Tree}; fn main() { for path_str in args().skip(1) { let repo = get_repository(&path_str); let...
} fn rebuild<'a>(oid: Oid, repo: &'a Repository, tree: &Tree<'a>, store: &HashMap<Oid, Data<'a>>) { let ref data = store[&oid]; let is_rebuilt = |c: Commit, store: &HashMap<Oid, Data>| { store[&c.id()].new_commit.borrow().is_some() }; if data.new_commit.borrow().is_none() && data.commit.parents...
} }
random_line_split
main.rs
extern crate git2; use std::cell::RefCell; use std::collections::HashMap; use std::env::args; use std::path::Path; use git2::{Branch, BranchType, Commit, ResetType, ObjectType, Oid, Repository, Signature, Tree}; fn main()
if!branch.is_head() { let new_commit = repo.find_commit(new_oid).unwrap(); repo.branch(branch.name().unwrap().unwrap(), &new_commit, true).unwrap(); } else { let new_commit = repo.find_object(new_oid, Some(ObjectType::Commit)).unwrap(); ...
{ for path_str in args().skip(1) { let repo = get_repository(&path_str); let mut store: HashMap<Oid, Data> = HashMap::new(); let mut roots = Vec::new(); for branch in get_branches(&repo).into_iter() { populate_from_branch(branch, &repo, &mut store, &mut roots) } ...
identifier_body
main.rs
extern crate git2; use std::cell::RefCell; use std::collections::HashMap; use std::env::args; use std::path::Path; use git2::{Branch, BranchType, Commit, ResetType, ObjectType, Oid, Repository, Signature, Tree}; fn main() { for path_str in args().skip(1) { let repo = get_repository(&path_str); let...
(commit: Commit<'a>) -> Data { Data { commit: commit, children: RefCell::new(Vec::new()), new_commit: RefCell::new(None), } } }
new
identifier_name
main.rs
extern crate git2; use std::cell::RefCell; use std::collections::HashMap; use std::env::args; use std::path::Path; use git2::{Branch, BranchType, Commit, ResetType, ObjectType, Oid, Repository, Signature, Tree}; fn main() { for path_str in args().skip(1) { let repo = get_repository(&path_str); let...
else { for child_oid in data.children.borrow().iter() { rebuild(*child_oid, repo, tree, store); } } } } fn get_parents<'a>(oid: Oid, repo: &'a Repository, store: &HashMap<Oid, Data<'a>>) -> Vec<Commit<'a>> { store[&oid].commit.parents().map(|commit| { r...
{ let author = Signature::new("Anonymous", "anon@ymo.us", &data.commit.author().when()); let committer = Signature::new("Anonymous", "anon@ymo.us", &data.commit.committer().when()); le...
conditional_block
issue-12133-3.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
issue-12133-3.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 ...
extern crate issue_12133_dylib2 as other; fn main() {}
// pretty-expanded FIXME #23616
random_line_split
issue-12133-3.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 ...
() {}
main
identifier_name
tags.rs
use super::util; use anyhow::{anyhow, Result}; use std::io::{self, Write}; use std::path::Path; use std::time::Instant; use std::{fs, str}; use tree_sitter_loader::Loader; use tree_sitter_tags::TagsContext; pub fn generate_tags( loader: &Loader, scope: Option<&str>, paths: &[String], quiet: bool, t...
let mut context = TagsContext::new(); let cancellation_flag = util::cancel_on_stdin(); let stdout = io::stdout(); let mut stdout = stdout.lock(); for path in paths { let path = Path::new(&path); let (language, language_config) = match lang { Some(v) => v, N...
{ lang = loader.language_configuration_for_scope(scope)?; if lang.is_none() { return Err(anyhow!("Unknown scope '{}'", scope)); } }
conditional_block
tags.rs
use super::util;
use std::time::Instant; use std::{fs, str}; use tree_sitter_loader::Loader; use tree_sitter_tags::TagsContext; pub fn generate_tags( loader: &Loader, scope: Option<&str>, paths: &[String], quiet: bool, time: bool, ) -> Result<()> { let mut lang = None; if let Some(scope) = scope { l...
use anyhow::{anyhow, Result}; use std::io::{self, Write}; use std::path::Path;
random_line_split
tags.rs
use super::util; use anyhow::{anyhow, Result}; use std::io::{self, Write}; use std::path::Path; use std::time::Instant; use std::{fs, str}; use tree_sitter_loader::Loader; use tree_sitter_tags::TagsContext; pub fn
( loader: &Loader, scope: Option<&str>, paths: &[String], quiet: bool, time: bool, ) -> Result<()> { let mut lang = None; if let Some(scope) = scope { lang = loader.language_configuration_for_scope(scope)?; if lang.is_none() { return Err(anyhow!("Unknown scope '{}...
generate_tags
identifier_name