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
build.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::fs; use std::io; use std::path::Path; fn check_signed_source() -> io::Result<()> { // Check if lib.rs is in sync with the Thr...
println!( "cargo:rerun-if-changed={}", &thrift_file_path.to_string_lossy() ); let thrift_file_content = fs::read_to_string(&thrift_file_path)?; let hash = "4bc06e1c39884f65a4e9cd145972df39"; if!thrift_file_content.contains(hash) { let msg = format!( "thrift_typ...
{ // Do not make it a fatal error on non-fbcode environment (ex. OSS). println!( "cargo:warning=Does not verify Thrift file at {}.", &thrift_file_path.display() ); return Ok(()); }
conditional_block
build.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::fs; use std::io; use std::path::Path; fn check_signed_source() -> io::Result<()> { // Check if lib.rs is in sync with the Thr...
{ check_signed_source() }
identifier_body
data_loader.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/. */ extern crate hyper; use ipc_channel::ipc; use net_traits::LoadConsumer::Channel; use net_traits::LoadData; use ne...
{ assert_parse("data:text/plain;charset=koi8-r;base64,8PLl9+XkIO3l5Pfl5A==", Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, vec!((Attr::Charset, Value::Ext("koi8-r".to_string())))))), Some("koi8-r".to_string()), Some(vec!(0xF0, 0xF2, 0xE5, 0xF7, 0xE5, 0x...
identifier_body
data_loader.rs
use ipc_channel::ipc; use net_traits::LoadConsumer::Channel; use net_traits::LoadData; use net_traits::ProgressMsg::{Payload, Done}; use self::hyper::header::ContentType; use self::hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value}; #[cfg(test)] fn assert_parse(url: &'static str, content_ty...
/* 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/. */ extern crate hyper;
random_line_split
data_loader.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/. */ extern crate hyper; use ipc_channel::ipc; use net_traits::LoadConsumer::Channel; use net_traits::LoadData; use ne...
() { assert_parse( "data:text/plain,hello", Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, vec!()))), None, Some(b"hello".iter().map(|&x| x).collect())); } #[test] fn plain_charset() { assert_parse("data:text/plain;charset=latin1,hello", Some(ContentType(Mime(Top...
plain_ct
identifier_name
type.rs
// rustfmt-normalize_comments: true fn types() { let x: [Vec<_>] = []; let y: *mut [SomeType; konst_funk()] = expr(); let z: (/* #digits */ usize, /* exp */ i16) = funk(); let z: (usize /* #digits */, i16 /* exp */) = funk(); } struct F { f: extern "C" fn(x: u8,... /* comment */), g: extern "C"...
<'a, T: Trait1 + Trait2 + 'a>( &fooo: u32, ) -> impl Future< Item = ( impl Future<Item = (), Error = SomeError> + 'a, impl Future<Item = (), Error = SomeError> + 'a, impl Future<Item = (), Error = SomeError> + 'a, ), Error = SomeError, > + 'a { } pub fn do_something<'a, T: Trait...
do_something
identifier_name
type.rs
// rustfmt-normalize_comments: true fn types() { let x: [Vec<_>] = []; let y: *mut [SomeType; konst_funk()] = expr(); let z: (/* #digits */ usize, /* exp */ i16) = funk(); let z: (usize /* #digits */, i16 /* exp */) = funk(); } struct F { f: extern "C" fn(x: u8,... /* comment */), g: extern "C"...
} // #4357 type T = typeof(1); impl T for.. {}
{ Self(t) }
identifier_body
type.rs
// rustfmt-normalize_comments: true fn types() { let x: [Vec<_>] = []; let y: *mut [SomeType; konst_funk()] = expr(); let z: (/* #digits */ usize, /* exp */ i16) = funk(); let z: (usize /* #digits */, i16 /* exp */) = funk(); } struct F { f: extern "C" fn(x: u8,... /* comment */), g: extern "C"...
{ } // #3117 fn issue3117() { { { { { { { { { let opt: &mut Option<MyLongTypeHere> = unsafe { &mut ...
where T: (FnOnce() -> ()) + Clone, U: (FnOnce() -> ()) + 'static,
random_line_split
ast.rs
//! JMESPath abstract syntax tree (AST). //! //! Inspecting the JMESPath AST can be useful for analyzing the way in //! which an expression was parsed and which features are utilized in //! an expression. //! //! Ast can be accessed directly from a parsed `jmespath::Expression` //! using the `as_ast()` method. An Ast c...
{ /// Key name. pub key: String, /// Value expression used to determine the value. pub value: Ast, } /// Comparators used in Comparison nodes. #[derive(Clone, PartialEq, Debug)] pub enum Comparator { Equal, NotEqual, LessThan, LessThanEqual, GreaterThan, GreaterThanEqual, } //...
KeyValuePair
identifier_name
ast.rs
//! JMESPath abstract syntax tree (AST). //! //! Inspecting the JMESPath AST can be useful for analyzing the way in //! which an expression was parsed and which features are utilized in //! an expression. //! //! Ast can be accessed directly from a parsed `jmespath::Expression` //! using the `as_ast()` method. An Ast c...
/// Key name. pub key: String, /// Value expression used to determine the value. pub value: Ast, } /// Comparators used in Comparison nodes. #[derive(Clone, PartialEq, Debug)] pub enum Comparator { Equal, NotEqual, LessThan, LessThanEqual, GreaterThan, GreaterThanEqual, } /// C...
/// Represents a key value pair in a MultiHash. #[derive(Clone, PartialEq, Debug)] pub struct KeyValuePair {
random_line_split
triangle.rs
#[macro_use] extern crate glium; mod support; use glium::Surface; use glium::glutin; use glium::index::PrimitiveType; fn main() { use glium::DisplayBuild; // building the display, ie. the main object let display = glutin::WindowBuilder::new() .build_glium() .unwrap(); // building the ...
uniform lowp mat4 matrix; attribute lowp vec2 position; attribute lowp vec3 color; varying lowp vec3 vColor; void main() { gl_Position = vec4(position, 0.0, 1.0) * matrix; vColor = color; ...
random_line_split
triangle.rs
#[macro_use] extern crate glium; mod support; use glium::Surface; use glium::glutin; use glium::index::PrimitiveType; fn
() { use glium::DisplayBuild; // building the display, ie. the main object let display = glutin::WindowBuilder::new() .build_glium() .unwrap(); // building the vertex buffer, which contains all the vertices that we will draw let vertex_buffer = { #[derive(Copy, Clone)] ...
main
identifier_name
triangle.rs
#[macro_use] extern crate glium; mod support; use glium::Surface; use glium::glutin; use glium::index::PrimitiveType; fn main()
Vertex { position: [-0.5, -0.5], color: [0.0, 1.0, 0.0] }, Vertex { position: [ 0.0, 0.5], color: [0.0, 0.0, 1.0] }, Vertex { position: [ 0.5, -0.5], color: [1.0, 0.0, 0.0] }, ] ) }; // building the index buffer let index_buffer = glium::...
{ use glium::DisplayBuild; // building the display, ie. the main object let display = glutin::WindowBuilder::new() .build_glium() .unwrap(); // building the vertex buffer, which contains all the vertices that we will draw let vertex_buffer = { #[derive(Copy, Clone)] ...
identifier_body
associated-types-multiple-types-one-trait.rs
trait Foo { type X; type Y; }
} fn have_x_want_y<T:Foo<X=u32>>(t: &T) { want_y(t); //~ ERROR type mismatch } fn have_y_want_x<T:Foo<Y=i32>>(t: &T) { want_x(t); //~ ERROR type mismatch } fn have_y_want_y<T:Foo<Y=i32>>(t: &T) { want_y(t); } fn have_xy_want_x<T:Foo<X=u32,Y=i32>>(t: &T) { want_x(t); } fn have_xy_want_y<T:Foo<X=u32,...
fn have_x_want_x<T:Foo<X=u32>>(t: &T) { want_x(t);
random_line_split
associated-types-multiple-types-one-trait.rs
trait Foo { type X; type Y; } fn have_x_want_x<T:Foo<X=u32>>(t: &T) { want_x(t); } fn have_x_want_y<T:Foo<X=u32>>(t: &T) { want_y(t); //~ ERROR type mismatch } fn have_y_want_x<T:Foo<Y=i32>>(t: &T) { want_x(t); //~ ERROR type mismatch } fn have_y_want_y<T:Foo<Y=i32>>(t: &T) { want_y(t); } f...
<T:Foo<X=u32>>(t: &T) { } fn want_y<T:Foo<Y=i32>>(t: &T) { } fn main() { }
want_x
identifier_name
associated-types-multiple-types-one-trait.rs
trait Foo { type X; type Y; } fn have_x_want_x<T:Foo<X=u32>>(t: &T) { want_x(t); } fn have_x_want_y<T:Foo<X=u32>>(t: &T) { want_y(t); //~ ERROR type mismatch } fn have_y_want_x<T:Foo<Y=i32>>(t: &T) { want_x(t); //~ ERROR type mismatch } fn have_y_want_y<T:Foo<Y=i32>>(t: &T) { want_y(t); } f...
fn want_y<T:Foo<Y=i32>>(t: &T) { } fn main() { }
{ }
identifier_body
simplify.rs
#[link(name = "simplify", vers = "0.0.6")]; extern mod extra; use extra::json::Json; use extra::json::List; use extra::json::ToJson; use extra::treemap::TreeSet; use std::vec; #[deriving(Clone, Eq)] pub struct Point { x: float, y: float } impl ToJson for Point { fn to_json(&self) -> Json { List(~[self.x.to_json(),s...
(self, other: float) -> Point { Point { x:self.x * other, y:self.y * other }} fn add(self, other: float) -> Point { Point {x:self.x + other, y:self.y + other }} } type Pair = (uint, uint); fn calcStuff(p:Point,p1:Point,d1:Point)->float { let top = ((p - p1) * d1).sum(); let bottom = d1.sqsum(); if bottom == 0.0 ...
mul
identifier_name
simplify.rs
#[link(name = "simplify", vers = "0.0.6")]; extern mod extra; use extra::json::Json; use extra::json::List; use extra::json::ToJson; use extra::treemap::TreeSet; use std::vec; #[deriving(Clone, Eq)] pub struct Point { x: float, y: float } impl ToJson for Point { fn to_json(&self) -> Json { List(~[self.x.to_json(),s...
}; (p-d2).sqsum() } fn simplifyRadialDistance(points:~[Point], sqTolerance:float) -> ~[Point]{ let mut it = points.iter(); it.next(); let mut prevPoint : Point = points[0u]; let mut newPoints : ~[Point] = ~[prevPoint]; let &last = points.last(); for &point in it{ if (point - prevPoint).sqsum() > sqTolerance ...
random_line_split
simplify.rs
#[link(name = "simplify", vers = "0.0.6")]; extern mod extra; use extra::json::Json; use extra::json::List; use extra::json::ToJson; use extra::treemap::TreeSet; use std::vec; #[deriving(Clone, Eq)] pub struct Point { x: float, y: float } impl ToJson for Point { fn to_json(&self) -> Json
} impl Sub<Point,Point> for Point { #[inline] fn sub(&self, other: &Point) -> Point { Point {x:self.x-other.x,y:self.y-other.y} } } impl Add<Point,Point> for Point { #[inline] fn add(&self, other: &Point) -> Point { Point { x:self.x+other.x,y:self.y+other.y }} } impl Mul<Point,Point> for Point { #[inline] fn mul...
{ List(~[self.x.to_json(),self.y.to_json()]) }
identifier_body
simplify.rs
#[link(name = "simplify", vers = "0.0.6")]; extern mod extra; use extra::json::Json; use extra::json::List; use extra::json::ToJson; use extra::treemap::TreeSet; use std::vec; #[deriving(Clone, Eq)] pub struct Point { x: float, y: float } impl ToJson for Point { fn to_json(&self) -> Json { List(~[self.x.to_json(),s...
else{ p1 } } }; (p-d2).sqsum() } fn simplifyRadialDistance(points:~[Point], sqTolerance:float) -> ~[Point]{ let mut it = points.iter(); it.next(); let mut prevPoint : Point = points[0u]; let mut newPoints : ~[Point] = ~[prevPoint]; let &last = points.last(); for &point in it{ if (point - prevPoin...
{ d1.mul(t)+p1 }
conditional_block
test_tr.rs
use common::util::*; #[test] fn test_toupper()
#[test] fn test_small_set2() { new_ucmd!() .args(&["0-9", "X"]).pipe_in("@0123456789").run().stdout_is("@XXXXXXXXXX"); } #[test] fn test_unicode() { new_ucmd!() .args(&[", ┬─┬", "╯︵┻━┻"]) .pipe_in("(,°□°), ┬─┬").run() .stdout_is("(╯°□°)╯︵┻━┻"); } #[test] fn test_delete() { ne...
{ new_ucmd!() .args(&["a-z", "A-Z"]).pipe_in("!abcd!").run().stdout_is("!ABCD!"); }
identifier_body
test_tr.rs
use common::util::*; #[test] fn test_toupper() { new_ucmd!() .args(&["a-z", "A-Z"]).pipe_in("!abcd!").run().stdout_is("!ABCD!"); } #[test] fn test_small_set2() { new_ucmd!() .args(&["0-9", "X"]).pipe_in("@0123456789").run().stdout_is("@XXXXXXXXXX"); } #[test] fn test_unicode() { new_ucmd!(...
}
.args(&["-d", "-c", "a-z"]).pipe_in("aBcD").run().stdout_is("ac");
random_line_split
test_tr.rs
use common::util::*; #[test] fn test_toupper() { new_ucmd!() .args(&["a-z", "A-Z"]).pipe_in("!abcd!").run().stdout_is("!ABCD!"); } #[test] fn test_small_set2() { new_ucmd!() .args(&["0-9", "X"]).pipe_in("@0123456789").run().stdout_is("@XXXXXXXXXX"); } #[test] fn test_unicode() { new_ucmd!(...
z"]).pipe_in("aBcD").run().stdout_is("BD"); } #[test] fn test_delete_complement() { new_ucmd!() .args(&["-d", "-c", "a-z"]).pipe_in("aBcD").run().stdout_is("ac"); }
&["-d", "a-
identifier_name
relocation.rs
use std::io::{Read, Write}; use {Error, Header, SectionContent}; use types; use num_traits::{FromPrimitive, ToPrimitive}; /* A Represents the addend used to compute the value of the relocatable field. B Represents the base address at which a shared object has been loaded into memory during execution. Generally, a sha...
R_X86_64_NONE = 0, // none none R_X86_64_64 = 1, // word64 S + A R_X86_64_PC32 = 2, // word32 S + A - P R_X86_64_GOT32 = 3, // word32 G + A R_X86_64_PLT32 = 4, // word32 L + A - P R_X86_64_COPY = 5, // none none R_X86_64_GLOB_DAT = 6, // wordclass S R_X86_...
locationType {
identifier_name
relocation.rs
use std::io::{Read, Write}; use {Error, Header, SectionContent}; use types; use num_traits::{FromPrimitive, ToPrimitive}; /* A Represents the addend used to compute the value of the relocatable field. B Represents the base address at which a shared object has been loaded into memory during execution. Generally, a sha...
"warning: unknown relocation type {} skipped while reading", rtype ); elf_read_u64!(eh, io)?; continue; } }; let addend = elf_read_u64!(eh, io)?; r.push(Reloc...
if eh.machine != types::Machine::X86_64 { return Err(Error::UnsupportedMachineTypeForRelocation( eh.machine.clone(), )); } let mut r = Vec::new(); while let Ok(addr) = elf_read_u64!(eh, io) { let info = match elf_read_u64!(eh, io) { ...
identifier_body
relocation.rs
use std::io::{Read, Write}; use {Error, Header, SectionContent}; use types; use num_traits::{FromPrimitive, ToPrimitive}; /* A Represents the addend used to compute the value of the relocatable field. B Represents the base address at which a shared object has been loaded into memory during execution. Generally, a sha...
R_X86_64_GOTPCREL = 9, // word32 G + GOT + A - P R_X86_64_32 = 10, // word32 S + A R_X86_64_32S = 11, // word32 S + A R_X86_64_16 = 12, // word16 S + A R_X86_64_PC16 = 13, // word16 S + A - P R_X86_64_8 = 14, // word8 S + A R_X86_64_PC8 = 15, // word8 S + A ...
R_X86_64_GLOB_DAT = 6, // wordclass S R_X86_64_JUMP_SLOT = 7, // wordclass S R_X86_64_RELATIVE = 8, // wordclass B + A
random_line_split
disk_space.rs
use std::path::Path; use std::time::Duration; use crossbeam_channel::Sender; use nix::sys::statvfs::statvfs; use serde_derive::Deserialize; use crate::blocks::{Block, ConfigBlock, Update}; use crate::config::SharedConfig; use crate::de::deserialize_duration; use crate::errors::*; use crate::formatting::FormatTemplate...
{ id: usize, disk_space: TextWidget, update_interval: Duration, path: String, unit: Prefix, info_type: InfoType, warning: f64, alert: f64, alert_absolute: bool, format: FormatTemplate, icon: String, // DEPRECATED // TODO remove alias: String, } #[derive(Deseria...
DiskSpace
identifier_name
disk_space.rs
use std::path::Path; use std::time::Duration; use crossbeam_channel::Sender; use nix::sys::statvfs::statvfs; use serde_derive::Deserialize; use crate::blocks::{Block, ConfigBlock, Update}; use crate::config::SharedConfig; use crate::de::deserialize_duration; use crate::errors::*; use crate::formatting::FormatTemplate...
; let state = self.compute_state(alert_val, self.warning, self.alert, alert_type); self.disk_space.set_state(state); Ok(Some(self.update_interval.into())) } fn view(&self) -> Vec<&dyn I3BarWidget> { vec![&self.disk_space] } fn id(&self) -> usize { self.id ...
{ percentage }
conditional_block
disk_space.rs
use std::path::Path; use std::time::Duration; use crossbeam_channel::Sender; use nix::sys::statvfs::statvfs; use serde_derive::Deserialize; use crate::blocks::{Block, ConfigBlock, Update}; use crate::config::SharedConfig; use crate::de::deserialize_duration; use crate::errors::*; use crate::formatting::FormatTemplate...
impl Block for DiskSpace { fn update(&mut self) -> Result<Option<Update>> { let statvfs = statvfs(Path::new(self.path.as_str())) .block_error("disk_space", "failed to retrieve statvfs")?; let total = (statvfs.blocks() as u64) * (statvfs.fragment_size() as u64); let used = ((statv...
}
random_line_split
async-fn-multiple-lifetimes.rs
// Copyright 2018 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 for<'b> Add<&'b u8>, _: &'c u8, ) {} async fn multiple_elided_lifetimes(_: &u8, _: &u8) {} //~^ ERROR multiple elided lifetimes used //~^^ ERROR missing lifetime specifier fn main() {}
async fn multiple_hrtb_and_single_named_lifetime_ok<'c>( _: impl for<'a> Add<&'a u8>,
random_line_split
async-fn-multiple-lifetimes.rs
// Copyright 2018 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 ...
async fn multiple_elided_lifetimes(_: &u8, _: &u8) {} //~^ ERROR multiple elided lifetimes used //~^^ ERROR missing lifetime specifier fn main() {}
{}
identifier_body
async-fn-multiple-lifetimes.rs
// Copyright 2018 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 ...
(_: &u8, _: &u8) {} //~^ ERROR multiple elided lifetimes used //~^^ ERROR missing lifetime specifier fn main() {}
multiple_elided_lifetimes
identifier_name
lazy-and-or.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 ...
}
{ assert!((false)); }
conditional_block
lazy-and-or.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.
// except according to those terms. fn incr(x: &mut int) -> bool { *x += 1; assert!((false)); return false; } pub fn main() { let x = 1 == 2 || 3 == 3; assert!((x)); let mut y: int = 10; println!("{:?}", x || incr(&mut y)); assert_eq!(y, 10); if true && x { assert!((true)); } else { assert!(...
// // 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
random_line_split
lazy-and-or.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 ...
{ let x = 1 == 2 || 3 == 3; assert!((x)); let mut y: int = 10; println!("{:?}", x || incr(&mut y)); assert_eq!(y, 10); if true && x { assert!((true)); } else { assert!((false)); } }
identifier_body
lazy-and-or.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 ...
(x: &mut int) -> bool { *x += 1; assert!((false)); return false; } pub fn main() { let x = 1 == 2 || 3 == 3; assert!((x)); let mut y: int = 10; println!("{:?}", x || incr(&mut y)); assert_eq!(y, 10); if true && x { assert!((true)); } else { assert!((false)); } }
incr
identifier_name
cube.rs
#[macro_use] extern crate glium; extern crate arcball; extern crate cgmath; use arcball::ArcballCamera; use cgmath::{Vector2, Vector3}; use glium::index::PrimitiveType; use glium::{glutin, Surface}; #[derive(Copy, Clone)] struct
{ pos: [f32; 3], color: [f32; 3], } implement_vertex!(Vertex, pos, color); // NOTE: This is still provided as an example of how to hook up mouse events // to the camera, however it should eventually be replaced by one using // device events (I think) since window events don't seem to fire often fn main() { ...
Vertex
identifier_name
cube.rs
#[macro_use] extern crate glium; extern crate arcball; extern crate cgmath; use arcball::ArcballCamera; use cgmath::{Vector2, Vector3}; use glium::index::PrimitiveType; use glium::{glutin, Surface}; #[derive(Copy, Clone)] struct Vertex { pos: [f32; 3], color: [f32; 3], } implement_vertex!(Vertex, pos, color);...
println!("prev = {:?}", prev_mouse); } glutin::event::WindowEvent::MouseInput { state, button,.. } => { if button == glutin::event::MouseButton::Left { mouse_pressed[0] = state == glutin::event::ElementState::Pressed; ...
arcball_camera.pan(mouse_delta); } prev_mouse = Some(position);
random_line_split
cube.rs
#[macro_use] extern crate glium; extern crate arcball; extern crate cgmath; use arcball::ArcballCamera; use cgmath::{Vector2, Vector3}; use glium::index::PrimitiveType; use glium::{glutin, Surface}; #[derive(Copy, Clone)] struct Vertex { pos: [f32; 3], color: [f32; 3], } implement_vertex!(Vertex, pos, color);...
glutin::event::WindowEvent::MouseInput { state, button,.. } => { if button == glutin::event::MouseButton::Left { mouse_pressed[0] = state == glutin::event::ElementState::Pressed; } else if button == glutin::event::MouseButton::Right { ...
{ let prev = prev_mouse.unwrap(); if mouse_pressed[0] { arcball_camera.rotate( Vector2::new(prev.x as f32, prev.y as f32), Vector2::new(position.x as f32, position.y as f32), )...
conditional_block
cube.rs
#[macro_use] extern crate glium; extern crate arcball; extern crate cgmath; use arcball::ArcballCamera; use cgmath::{Vector2, Vector3}; use glium::index::PrimitiveType; use glium::{glutin, Surface}; #[derive(Copy, Clone)] struct Vertex { pos: [f32; 3], color: [f32; 3], } implement_vertex!(Vertex, pos, color);...
}, Vertex { pos: [1.0, 1.0, 1.0], color: [1.0, 0.0, 0.0], }, Vertex { pos: [-1.0, 1.0, 1.0], color: [0.0, 1.0, 0.0], }, Vertex { pos: [-1.0, -1.0, 1.0], ...
{ let window = glutin::window::WindowBuilder::new().with_title("Arcball Camera Cube Example"); let context = glutin::ContextBuilder::new() .with_vsync(true); let event_loop = glutin::event_loop::EventLoop::new(); let display = glium::Display::new(window, context, &event_loop).expect("fa...
identifier_body
errors.rs
use std::convert::{self, From}; use std::error; use std::fmt; use std::io; use std::string; use std::sync; use rusty_leveldb::Status; use crate::blockchain::proto::script; /// Returns a string with filename, current code line and column macro_rules! line_mark { () => { format!("Marked line: {} @ {}:{}", ...
} } #[derive(Debug)] pub enum OpErrorKind { None, IoError(io::Error), ByteOrderError(io::Error), Utf8Error(string::FromUtf8Error), ScriptError(script::ScriptError), InvalidArgsError, CallbackError, ValidateError, RuntimeError, PoisonError, SendError, LevelDBError(Str...
self.message.as_ref() } fn cause(&self) -> Option<&dyn error::Error> { self.kind.source()
random_line_split
errors.rs
use std::convert::{self, From}; use std::error; use std::fmt; use std::io; use std::string; use std::sync; use rusty_leveldb::Status; use crate::blockchain::proto::script; /// Returns a string with filename, current code line and column macro_rules! line_mark { () => { format!("Marked line: {} @ {}:{}", ...
(err: String) -> Self { Self::new(OpErrorKind::None).join_msg(&err) } } impl<T> convert::From<sync::PoisonError<T>> for OpError { fn from(_: sync::PoisonError<T>) -> Self { Self::new(OpErrorKind::PoisonError) } } impl<T> convert::From<sync::mpsc::SendError<T>> for OpError { fn from(_: ...
from
identifier_name
errors.rs
use std::convert::{self, From}; use std::error; use std::fmt; use std::io; use std::string; use std::sync; use rusty_leveldb::Status; use crate::blockchain::proto::script; /// Returns a string with filename, current code line and column macro_rules! line_mark { () => { format!("Marked line: {} @ {}:{}", ...
} impl convert::From<rusty_leveldb::Status> for OpError { fn from(status: Status) -> Self { Self::new(OpErrorKind::LevelDBError(status.err)) } } #[cfg(test)] mod tests { use super::*; use std::io; #[test] fn test_op_error() { let kind = io::Error::new(io::ErrorKind::BrokenPip...
{ Self::new(OpErrorKind::Utf8Error(err)) }
identifier_body
cursor.rs
use crate::{ proc_macros::IntoRenderObject, render_object::*, utils::{Brush, Point, Rectangle, Thickness}, }; /// The `CursorRenderObject` is used to render the `Cursor` widget. /// /// [`Cursor`]:../../widgets/struct.Cursor.html #[derive(Debug, IntoRenderObject)] pub struct
; impl RenderObject for CursorRenderObject { fn render_self(&self, ctx: &mut Context, global_position: &Point) { let ( bounds, background, border_width, border_brush, background_opacity, cursor_x, selection_width, ...
CursorRenderObject
identifier_name
cursor.rs
use crate::{ proc_macros::IntoRenderObject, render_object::*, utils::{Brush, Point, Rectangle, Thickness}, }; /// The `CursorRenderObject` is used to render the `Cursor` widget. /// /// [`Cursor`]:../../widgets/struct.Cursor.html #[derive(Debug, IntoRenderObject)] pub struct CursorRenderObject; impl Rende...
*widget.get::<f64>("selection_width"), *widget.get::<f64>("selection_x"), *widget.get::<f64>("offset"), ) }; let border_width = border_width.right(); // background ctx.render_context_2_d().set_alpha(background_opacity); ...
{ let ( bounds, background, border_width, border_brush, background_opacity, cursor_x, selection_width, selection_x, offset, ) = { let widget = ctx.widget(); ( ...
identifier_body
cursor.rs
use crate::{ proc_macros::IntoRenderObject, render_object::*, utils::{Brush, Point, Rectangle, Thickness}, }; /// The `CursorRenderObject` is used to render the `Cursor` widget. /// /// [`Cursor`]:../../widgets/struct.Cursor.html #[derive(Debug, IntoRenderObject)] pub struct CursorRenderObject; impl Rende...
*widget.get::<Rectangle>("bounds"), widget.get::<Brush>("background").clone(), *widget.get::<Thickness>("border_width"), widget.clone_or_default::<Brush>("border_brush"), *widget.get::<f32>("background_opacity"), *widget.get...
selection_x, offset, ) = { let widget = ctx.widget(); (
random_line_split
message.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/. */ use {OpaqueStyleAndLayoutData, PendingImage, TrustedNodeAddress}; use app_units::Au; use euclid::{Point2D, Rect}; ...
{ /// General reflow data. pub reflow_info: Reflow, /// The document node. pub document: TrustedNodeAddress, /// Whether the document's stylesheets have changed since the last script reflow. pub stylesheets_changed: bool, /// The current window size. pub window_size: WindowSizeData, ...
ScriptReflow
identifier_name
message.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/. */ use {OpaqueStyleAndLayoutData, PendingImage, TrustedNodeAddress}; use app_units::Au; use euclid::{Point2D, Rect}; ...
} /// Information needed for a reflow. pub struct Reflow { /// A clipping rectangle for the page, an enlarged rectangle containing the viewport. pub page_clip_rect: Rect<Au>, } /// Information derived from a layout pass that needs to be returned to the script thread. #[derive(Default)] pub struct ReflowComp...
{ match *self { ReflowGoal::Full | ReflowGoal::TickAnimations => true, ReflowGoal::LayoutQuery(ref querymsg, _) => match querymsg { &QueryMsg::NodesFromPointQuery(..) | &QueryMsg::TextIndexQuery(..) | &QueryMsg::ElementInnerTextQuery(_) => ...
identifier_body
message.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/. */ use {OpaqueStyleAndLayoutData, PendingImage, TrustedNodeAddress}; use app_units::Au; use euclid::{Point2D, Rect}; ...
} /// Information needed for a reflow. pub struct Reflow { /// A clipping rectangle for the page, an enlarged rectangle containing the viewport. pub page_clip_rect: Rect<Au>, } /// Information derived from a layout pass that needs to be returned to the script thread. #[derive(Default)] pub struct ReflowCompl...
&QueryMsg::OffsetParentQuery(_) | &QueryMsg::StyleQuery(_) => false, }, } }
random_line_split
terrain.rs
use building_blocks::storage; use building_blocks::{ mesh::{IsOpaque, MergeVoxel, SignedDistance}, storage::IsEmpty, }; pub const EMPTY_VOXEL: Voxel = Voxel { voxel_type: VoxelType::Air, distance: VoxelDistance(1), }; pub const NUM_VOXEL_TYPES: usize = 5; #[derive(Clone, Copy, Debug)] pub struct Voxe...
VoxelType::Air => true, VoxelType::Stone | VoxelType::Grass | VoxelType::Gold | VoxelType::Water => false, } } } #[derive(Clone, Copy, Debug)] pub struct VoxelDistance(pub i8);
fn is_empty(&self) -> bool { match self {
random_line_split
terrain.rs
use building_blocks::storage; use building_blocks::{ mesh::{IsOpaque, MergeVoxel, SignedDistance}, storage::IsEmpty, }; pub const EMPTY_VOXEL: Voxel = Voxel { voxel_type: VoxelType::Air, distance: VoxelDistance(1), }; pub const NUM_VOXEL_TYPES: usize = 5; #[derive(Clone, Copy, Debug)] pub struct Voxe...
pub fn collidable(&self) -> bool { match self { VoxelType::Air | VoxelType::Water => false, VoxelType::Stone | VoxelType::Grass | VoxelType::Gold => true, } } } impl MergeVoxel for VoxelType { type VoxelValue = Self; fn voxel_merge_value(&self) -> Self::VoxelV...
{ match self { VoxelType::Air => 0, VoxelType::Stone => 1, VoxelType::Grass => 2, VoxelType::Gold => 3, VoxelType::Water => 4, } }
identifier_body
terrain.rs
use building_blocks::storage; use building_blocks::{ mesh::{IsOpaque, MergeVoxel, SignedDistance}, storage::IsEmpty, }; pub const EMPTY_VOXEL: Voxel = Voxel { voxel_type: VoxelType::Air, distance: VoxelDistance(1), }; pub const NUM_VOXEL_TYPES: usize = 5; #[derive(Clone, Copy, Debug)] pub struct Voxe...
(&self) -> bool { match self { VoxelType::Air | VoxelType::Water => false, VoxelType::Stone | VoxelType::Grass | VoxelType::Gold => true, } } } impl MergeVoxel for VoxelType { type VoxelValue = Self; fn voxel_merge_value(&self) -> Self::VoxelValue { *self ...
collidable
identifier_name
use.rs
// ignore-fast // 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 licens...
use x = zed::str; mod baz { pub use bar::str; pub use x = std::str; } #[start] pub fn start(_: int, _: **u8) -> int { 0 }
extern crate zed = "std"; extern crate bar = "std#0.10"; use std::str;
random_line_split
use.rs
// ignore-fast // 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 licens...
{ 0 }
identifier_body
use.rs
// ignore-fast // 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 licens...
(_: int, _: **u8) -> int { 0 }
start
identifier_name
misc.rs
//! Miscellaneous type-system utilities that are too small to deserve their own modules. use crate::infer::InferCtxtExt as _; use crate::traits::{self, ObligationCause}; use rustc_hir as hir; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use crate::traits::error_repo...
let (adt, substs) = match self_type.kind() { // These types used to have a builtin impl. // Now libcore provides that impl. ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) | ty::Char | ty::RawPtr(..) |...
) -> Result<(), CopyImplementationError<'tcx>> { // FIXME: (@jroesch) float this code up tcx.infer_ctxt().enter(|infcx| {
random_line_split
misc.rs
//! Miscellaneous type-system utilities that are too small to deserve their own modules. use crate::infer::InferCtxtExt as _; use crate::traits::{self, ObligationCause}; use rustc_hir as hir; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use crate::traits::error_repo...
( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, self_type: Ty<'tcx>, ) -> Result<(), CopyImplementationError<'tcx>> { // FIXME: (@jroesch) float this code up tcx.infer_ctxt().enter(|infcx| { let (adt, substs) = match self_type.kind() { // These types used to have a builtin im...
can_type_implement_copy
identifier_name
misc.rs
//! Miscellaneous type-system utilities that are too small to deserve their own modules. use crate::infer::InferCtxtExt as _; use crate::traits::{self, ObligationCause}; use rustc_hir as hir; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use crate::traits::error_repo...
let mut infringing = Vec::new(); for variant in &adt.variants { for field in &variant.fields { let ty = field.ty(tcx, substs); if ty.references_error() { continue; } let span = tcx.def_span(field.did); ...
{ // FIXME: (@jroesch) float this code up tcx.infer_ctxt().enter(|infcx| { let (adt, substs) = match self_type.kind() { // These types used to have a builtin impl. // Now libcore provides that impl. ty::Uint(_) | ty::Int(_) | ty::Bool ...
identifier_body
match_wildcard_for_single_variants.rs
// run-rustfix #![warn(clippy::match_wildcard_for_single_variants)] #![allow(dead_code)] enum Foo { A, B, C, } enum Color { Red, Green, Blue, Rgb(u8, u8, u8), } impl Color { fn f(self) { match self { Self::Red => (), Self::Green => (), Self:...
() { let f = Foo::A; match f { Foo::A => {}, Foo::B => {}, _ => {}, } let color = Color::Red; // check exhaustive bindings match color { Color::Red => {}, Color::Green => {}, Color::Rgb(_r, _g, _b) => {}, _ => {}, } // check exha...
main
identifier_name
match_wildcard_for_single_variants.rs
// run-rustfix #![warn(clippy::match_wildcard_for_single_variants)] #![allow(dead_code)] enum Foo { A, B, C, } enum Color { Red, Green, Blue, Rgb(u8, u8, u8), } impl Color { fn f(self) { match self { Self::Red => (), Self::Green => (), Self:...
use self::Color as C; match color { C::Red => (), C::Green => (), C::Rgb(..) => (), _ => (), } match color { C::Red => (), Color::Green => (), Color::Rgb(..) => (), _ => (), } match Some(0) { Some(0) => 0, Some(_)...
&_ => (), }
random_line_split
match_wildcard_for_single_variants.rs
// run-rustfix #![warn(clippy::match_wildcard_for_single_variants)] #![allow(dead_code)] enum Foo { A, B, C, } enum Color { Red, Green, Blue, Rgb(u8, u8, u8), } impl Color { fn f(self)
} fn main() { let f = Foo::A; match f { Foo::A => {}, Foo::B => {}, _ => {}, } let color = Color::Red; // check exhaustive bindings match color { Color::Red => {}, Color::Green => {}, Color::Rgb(_r, _g, _b) => {}, _ => {}, } //...
{ match self { Self::Red => (), Self::Green => (), Self::Blue => (), _ => (), }; }
identifier_body
absolute.rs
use std::{cell::RefCell, collections::BTreeMap}; use dces::prelude::*; use crate::{ proc_macros::IntoLayout, render::RenderContext2D, theming::*, tree::Tree, utils::prelude::*, widget_base::mark_as_dirty, }; use super::{component, component_try_mut, Layout}; /// Place widgets absolute on the screen. #[deriv...
} *self.desired_size.borrow() } fn arrange( &self, render_context_2_d: &mut RenderContext2D, _parent_size: (f64, f64), entity: Entity, ecm: &mut EntityComponentManager<Tree>, layouts: &BTreeMap<Entity, Box<dyn Layout>>, theme: &Theme, ...
{ let dirty = child_layout .measure(render_context_2_d, child, ecm, layouts, theme) .dirty() || self.desired_size.borrow().dirty(); self.desired_size.borrow_mut().set_dirty(dirty); }
conditional_block
absolute.rs
use std::{cell::RefCell, collections::BTreeMap}; use dces::prelude::*; use crate::{ proc_macros::IntoLayout, render::RenderContext2D, theming::*, tree::Tree, utils::prelude::*, widget_base::mark_as_dirty, }; use super::{component, component_try_mut, Layout}; /// Place widgets absolute on the screen. #[deriv...
.set_size(bounds.width(), bounds.height()); } // walk down and arrange the addressed childs for index in 0..ecm.entity_store().children[&entity].len() { let child = ecm.entity_store().children[&entity][index]; if let Some(child_layout) = layouts.get(&child...
random_line_split
absolute.rs
use std::{cell::RefCell, collections::BTreeMap}; use dces::prelude::*; use crate::{ proc_macros::IntoLayout, render::RenderContext2D, theming::*, tree::Tree, utils::prelude::*, widget_base::mark_as_dirty, }; use super::{component, component_try_mut, Layout}; /// Place widgets absolute on the screen. #[deriv...
() -> Self { AbsoluteLayout::default() } } impl Layout for AbsoluteLayout { fn measure( &self, render_context_2_d: &mut RenderContext2D, entity: Entity, ecm: &mut EntityComponentManager<Tree>, layouts: &BTreeMap<Entity, Box<dyn Layout>>, theme: &Theme, ...
new
identifier_name
dump_process_registers.rs
//! A script to read and dump to stdout the current register values of a //! process. extern crate libc; extern crate mach; use std::io; use std::mem; use std::ptr; use mach::kern_return::{KERN_SUCCESS}; use mach::message::{mach_msg_type_number_t}; use mach::port::{mach_port_name_t}; use mach::structs::{x86_thread_s...
if kret!= KERN_SUCCESS { println!("Did not succeed in getting task's thread state"); println!("kern_return_t error {}", kret); continue; } println!("{:?}", state); } } resume(task as task_t); println!("Success!"); ...
let kret = thread_get_state(thread, x86_THREAD_STATE64, mem::transmute(&state), mem::transmute(&state_count));
random_line_split
dump_process_registers.rs
//! A script to read and dump to stdout the current register values of a //! process. extern crate libc; extern crate mach; use std::io; use std::mem; use std::ptr; use mach::kern_return::{KERN_SUCCESS}; use mach::message::{mach_msg_type_number_t}; use mach::port::{mach_port_name_t}; use mach::structs::{x86_thread_s...
() { print!("Enter pid: "); io::stdout().flush().ok(); let pid = match read_int() { Ok(v) => v, Err(_) => { println!("Bad pid!"); return; }, }; println!("pid = {}", &pid); let task : mach_port_name_t = 0; unsafe { let kret = task_for...
main
identifier_name
dump_process_registers.rs
//! A script to read and dump to stdout the current register values of a //! process. extern crate libc; extern crate mach; use std::io; use std::mem; use std::ptr; use mach::kern_return::{KERN_SUCCESS}; use mach::message::{mach_msg_type_number_t}; use mach::port::{mach_port_name_t}; use mach::structs::{x86_thread_s...
fn resume(task: task_t) { unsafe { let kret = task_resume(task); if kret!= KERN_SUCCESS { println!("Did not succeed in resuming task."); println!("kern_return_t error {}", kret); panic!(); } } } fn main() { print!("Enter pid: "); io::stdout(...
{ let stdin = io::stdin(); let mut line = String::new(); stdin.read_line(&mut line).ok().unwrap(); let mut value : ::libc::c_int = 0; for c in line.chars().take_while(|&c| c != '\n') { if let Some(d) = c.to_digit(10) { value = value * 10 + (d as ::libc::c_int); } else {...
identifier_body
output.rs
/// The types used by the generated parser to convert C4 into something usable /// by the accessor. /// Key-Value #[derive(Clone)] pub struct Property { id: String, value: String } impl Property { pub fn new(_id: String, _value: String) -> Self { Property { id: _id, value: _value } } } /// An...
fn check_cfg<F>(c: &str, f: F) where F: Fn(Configuration) { match configuration(c) { Ok(c) => f(c), Err(e) => dump_error_and_fail(e) } } #[test] fn test_simple_config() { check_cfg( r##" $country="us" $region="wes...
}
random_line_split
output.rs
/// The types used by the generated parser to convert C4 into something usable /// by the accessor. /// Key-Value #[derive(Clone)] pub struct Property { id: String, value: String } impl Property { pub fn new(_id: String, _value: String) -> Self
} /// An invocation of a selector, with the id of the selector and the value it /// must have to match. #[derive(Clone)] pub struct Selection { id: String, value: String } impl Selection { pub fn new(_id: String, _value: String) -> Self { Selection { id: _id, value: _value } } } /// The set...
{ Property { id: _id, value: _value } }
identifier_body
output.rs
/// The types used by the generated parser to convert C4 into something usable /// by the accessor. /// Key-Value #[derive(Clone)] pub struct Property { id: String, value: String } impl Property { pub fn new(_id: String, _value: String) -> Self { Property { id: _id, value: _value } } } /// An...
(&mut self, s: Selection) { self.selections.push(s) } pub fn with_selection(&self, s: Selection) -> Self { let mut ss = self.selections.clone(); ss.push(s); SelectionSet { selections: ss,.. *self } } } /// An expression is either a vector of selection sets surrounding some...
add_selection
identifier_name
problems.rs
//! Test Driven Learning Project. //! Desenvolva TDD e programação com TDD e programação! //! Módulo novice. //! //! The MIT License (MIT) //! //! Copyright (c) 2016 Paulo Henrique Rodrigues Pinheiro <paulohrpinheiro@gmail.com> //! //! Permission is hereby granted, free of charge, to any person obtaining a copy //! of ...
identifier_name
problems.rs
//! Test Driven Learning Project. //! Desenvolva TDD e programação com TDD e programação! //! Módulo novice. //! //! The MIT License (MIT) //! //! Copyright (c) 2016 Paulo Henrique Rodrigues Pinheiro <paulohrpinheiro@gmail.com> //! //! Permission is hereby granted, free of charge, to any person obtaining a copy //! of ...
-1 } /// A função `divisao` deve receber um *array* de números inteiros, e /// retornar o resultado da sequência de divisões por cada elemento. Por /// exemplo, divisão([16, 4, 2]) deve retornar 2, e divisão([100,2,10]) deve /// retornar 5. Se a lista for vazia, deve retornar zero. /// /// Examples /// /// ``` //...
/// assert_eq!(0, rust::problems::multiplicacao(vec![])); /// assert_eq!(-8, rust::problems::multiplicacao(vec![-2, 1, 4])); /// assert_eq!(8, rust::problems::multiplicacao(vec![-2, -1, 4])); pub fn multiplicacao(lista:Vec<i32>) -> i32 {
random_line_split
problems.rs
//! Test Driven Learning Project. //! Desenvolva TDD e programação com TDD e programação! //! Módulo novice. //! //! The MIT License (MIT) //! //! Copyright (c) 2016 Paulo Henrique Rodrigues Pinheiro <paulohrpinheiro@gmail.com> //! //! Permission is hereby granted, free of charge, to any person obtaining a copy //! of ...
unção `diga_ola` deve ser escrita de tal forma que receba como /// parâmetro um argumento *string*. Deve retornar a *string* "Olá, ", seguida /// do argumento recebido, mais um ponto final. A *string* recebida deve estar /// limpa, ou seja, sem caracteres de espaço no começo ou no fim. Se a *string* /// estiver vazia, ...
e } /// A f
identifier_body
framerate.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/. */ use actor::{Actor, ActorRegistry, ActorMessageStatus}; use actors::timeline::HighResolutionStamp; use devtools_tra...
pub fn add_tick(&mut self, tick: f64) { self.ticks.push(HighResolutionStamp::wrap(tick)); if self.is_recording { let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline, self.name()); self....
{ let actor_name = registry.new_name("framerate"); let mut actor = FramerateActor { name: actor_name.clone(), pipeline: pipeline_id, script_sender: script_sender, start_time: None, is_recording: false, ticks: Vec::new(), }; ...
identifier_body
framerate.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/. */ use actor::{Actor, ActorRegistry, ActorMessageStatus}; use actors::timeline::HighResolutionStamp; use devtools_tra...
(&mut self) { if self.is_recording { return; } self.start_time = Some(precise_time_ns()); self.is_recording = true; let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline, self.name());...
start_recording
identifier_name
framerate.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/. */ use actor::{Actor, ActorRegistry, ActorMessageStatus}; use actors::timeline::HighResolutionStamp; use devtools_tra...
return; } self.start_time = Some(precise_time_ns()); self.is_recording = true; let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline, self.name()); self.script_sender.send(msg).unwrap(...
mem::replace(&mut self.ticks, Vec::new()) } fn start_recording(&mut self) { if self.is_recording {
random_line_split
framerate.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/. */ use actor::{Actor, ActorRegistry, ActorMessageStatus}; use actors::timeline::HighResolutionStamp; use devtools_tra...
self.start_time = Some(precise_time_ns()); self.is_recording = true; let msg = DevtoolScriptControlMsg::RequestAnimationFrame(self.pipeline, self.name()); self.script_sender.send(msg).unwrap(); } fn stop_recordi...
{ return; }
conditional_block
cci_impl_exe.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 ...
extern mod cci_impl_lib; use cci_impl_lib::uint_helpers; pub fn main() { //let bt0 = sys::frame_address(); //info!("%?", bt0); 3u.to(10u, |i| { println!("{}", i); //let bt1 = sys::frame_address(); //info!("%?", bt1); //assert!(bt0 == bt1); }) }
// except according to those terms. // xfail-fast - check-fast doesn't understand aux-build // aux-build:cci_impl_lib.rs
random_line_split
cci_impl_exe.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 ...
{ //let bt0 = sys::frame_address(); //info!("%?", bt0); 3u.to(10u, |i| { println!("{}", i); //let bt1 = sys::frame_address(); //info!("%?", bt1); //assert!(bt0 == bt1); }) }
identifier_body
cci_impl_exe.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 ...
() { //let bt0 = sys::frame_address(); //info!("%?", bt0); 3u.to(10u, |i| { println!("{}", i); //let bt1 = sys::frame_address(); //info!("%?", bt1); //assert!(bt0 == bt1); }) }
main
identifier_name
image_cache_task.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/. */ use image::base::Image; use url::Url; use std::sync::Arc; use std::sync::mpsc::{channel, Sender}; /// This is opt...
#[derive(Clone)] pub struct ImageCacheChan(pub Sender<ImageCacheResult>); /// The result of an image cache command that is returned to the /// caller. pub struct ImageCacheResult { pub responder: Option<Box<ImageResponder>>, pub image_response: ImageResponse, } /// Commands that the image cache understands. p...
} /// Channel for sending commands to the image cache.
random_line_split
image_cache_task.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/. */ use image::base::Image; use url::Url; use std::sync::Arc; use std::sync::mpsc::{channel, Sender}; /// This is opt...
{ pub responder: Option<Box<ImageResponder>>, pub image_response: ImageResponse, } /// Commands that the image cache understands. pub enum ImageCacheCommand { /// Request an image asynchronously from the cache. Supply a channel /// to receive the result, and optionally an image responder /// that ...
ImageCacheResult
identifier_name
day19.rs
use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::HashSet; struct Replacement { before: String, after: String, } fn replace(med: &str, rep: &Replacement) -> Vec<String> { let mut meds: Vec<String> = Vec::new(); let parts: Vec<&str> = med.split(&rep.before).collect...
let mut meds = HashSet::new(); for r in &replacements { for m in replace(&medecine, &r) { meds.insert(m); } } println!("{}", meds.len()); let mut reversed: Vec<Replacement> = Vec::new(); for r in &replacements { reversed.push(Replacement{ before:...
random_line_split
day19.rs
use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::HashSet; struct Replacement { before: String, after: String, } fn replace(med: &str, rep: &Replacement) -> Vec<String> { let mut meds: Vec<String> = Vec::new(); let parts: Vec<&str> = med.split(&rep.before).collect...
new_med = new_med + parts[j]; } meds.push(new_med); } meds } fn search(med: &str, reps: &Vec<Replacement>) -> u32 { struct State { molecule: String, steps: u32 } let mut queue: Vec<State> = Vec::new(); queue.push( State{ molecul...
{ new_med = new_med + &rep.before; }
conditional_block
day19.rs
use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::HashSet; struct Replacement { before: String, after: String, } fn replace(med: &str, rep: &Replacement) -> Vec<String> { let mut meds: Vec<String> = Vec::new(); let parts: Vec<&str> = med.split(&rep.before).collect...
(med: &str, reps: &Vec<Replacement>) -> u32 { struct State { molecule: String, steps: u32 } let mut queue: Vec<State> = Vec::new(); queue.push( State{ molecule: med.to_string(), steps: 0, } ); while!queue.is_empty() { let s = queue...
search
identifier_name
issue-31948-2.rs
// Copyright 2016 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 ...
// @!has issue_31948_2/trait.Bark.html
random_line_split
term.rs
// Copyright 2013 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 unwrap(self) -> T { self.out } pub fn get_ref<'a>(&'a self) -> &'a T { &self.out } pub fn get_mut<'a>(&'a mut self) -> &'a mut T { &mut self.out } } impl<T: Writer> Writer for Terminal<T> { fn write(&mut self, buf: &[u8]) { self.out.write(buf); } fn flush(&mut self) { ...
{ color }
conditional_block
term.rs
// Copyright 2013 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 ...
/// the corresponding normal color will be used instead. /// /// Returns true if the color was set, false otherwise. pub fn fg(&mut self, color: color::Color) -> bool { let color = self.dim_if_necessary(color); if self.num_colors > color { let s = expand(*self.ti.strings.find...
} /// Sets the foreground color to the given color. /// /// If the color is a bright color, but the terminal only supports 8 colors,
random_line_split
term.rs
// Copyright 2013 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 ...
(&mut self) { self.out.flush(); } }
flush
identifier_name
properties.rs
extern crate dbus; use dbus::{Connection, BusType, stdintf}; fn
() { // Connect to server and create a ConnPath. A ConnPath implements several interfaces, // in this case we'll use OrgFreedesktopDBusProperties, which allows us to call "get". let c = Connection::get_private(BusType::Session).unwrap(); let p = c.with_path("org.mpris.MediaPlayer2.rhythmbox", "/org/mpri...
main
identifier_name
properties.rs
extern crate dbus; use dbus::{Connection, BusType, stdintf}; fn main()
if let Some(s) = value.as_str() { println!("{}", s); } else if let Some(i) = value.as_i64() { println!("{}", i); } else { println!("{:?}", value); } } }
{ // Connect to server and create a ConnPath. A ConnPath implements several interfaces, // in this case we'll use OrgFreedesktopDBusProperties, which allows us to call "get". let c = Connection::get_private(BusType::Session).unwrap(); let p = c.with_path("org.mpris.MediaPlayer2.rhythmbox", "/org/mpris/M...
identifier_body
properties.rs
extern crate dbus; use dbus::{Connection, BusType, stdintf}; fn main() { // Connect to server and create a ConnPath. A ConnPath implements several interfaces, // in this case we'll use OrgFreedesktopDBusProperties, which allows us to call "get". let c = Connection::get_private(BusType::Session).unwrap(); ...
// When using "as_iter()" for a dict, we'll get one key, it's value, next key, it's value, etc. // The ".0" is needed to traverse into the variant. let mut iter = metadata.0.as_iter().unwrap(); while let Some(key) = iter.next() { // Printing the key is easy, since we know it's a String. ...
let metadata = p.get("org.mpris.MediaPlayer2.Player", "Metadata").unwrap(); // The Metadata property is a Dict<String, Variant>, we can get the values out by iterating over it.
random_line_split
properties.rs
extern crate dbus; use dbus::{Connection, BusType, stdintf}; fn main() { // Connect to server and create a ConnPath. A ConnPath implements several interfaces, // in this case we'll use OrgFreedesktopDBusProperties, which allows us to call "get". let c = Connection::get_private(BusType::Session).unwrap(); ...
else if let Some(i) = value.as_i64() { println!("{}", i); } else { println!("{:?}", value); } } }
{ println!("{}", s); }
conditional_block
generic-object.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 ...
let y = x as ~Foo<int>; assert_eq!(y.get(), 1); }
random_line_split
generic-object.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) -> int { self.x } } pub fn main() { let x = ~S { x: 1 }; let y = x as ~Foo<int>; assert_eq!(y.get(), 1); }
get
identifier_name
generic-object.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 ...
{ let x = ~S { x: 1 }; let y = x as ~Foo<int>; assert_eq!(y.get(), 1); }
identifier_body
build-assets.rs
use anyhow::Context; use std::{ path::{Path, PathBuf}, process::Command, }; const DOCKER_IMAGE_REPO: &str = "https://github.com/z88dk/z88dk.git"; const DOCKER_IMAGE_COMMIT: &str = "d61f6bb46ec15775cccf543f5941b6a2d6864ecf"; const DOCKER_IMAGE_NAME: &str = "rustzx/z88dk"; const DOCKER_IMAGE_FILE: &str = "z88dk....
pub fn mount(mut self, mount_point: DockerMountPoint) -> Self { self.mount_points.push(mount_point); self } pub fn remove_after_run(mut self) -> Self { self.remove_after_run = true; self } pub fn startup_script(mut self, path: ForeignOsPath) -> Self { self...
{ self.name.replace(name.into()); self }
identifier_body
build-assets.rs
use anyhow::Context; use std::{ path::{Path, PathBuf}, process::Command, }; const DOCKER_IMAGE_REPO: &str = "https://github.com/z88dk/z88dk.git"; const DOCKER_IMAGE_COMMIT: &str = "d61f6bb46ec15775cccf543f5941b6a2d6864ecf"; const DOCKER_IMAGE_NAME: &str = "rustzx/z88dk"; const DOCKER_IMAGE_FILE: &str = "z88dk....
cmd.arg(self.url); cmd.spawn()?.wait()?; execute_command_transparent(cmd)?; Ok(()) } } fn to_container_name(prefix: &str) -> String { format!("{}-{}", prefix, nanoid::nanoid!(8, &HEX_ALPHABET)) } fn execute_command_transparent(mut cmd: Command) -> anyhow::Result<()> { print...
cmd.args(["-t", &name]); }
random_line_split
build-assets.rs
use anyhow::Context; use std::{ path::{Path, PathBuf}, process::Command, }; const DOCKER_IMAGE_REPO: &str = "https://github.com/z88dk/z88dk.git"; const DOCKER_IMAGE_COMMIT: &str = "d61f6bb46ec15775cccf543f5941b6a2d6864ecf"; const DOCKER_IMAGE_NAME: &str = "rustzx/z88dk"; const DOCKER_IMAGE_FILE: &str = "z88dk....
(mut self, name: impl Into<String>) -> Self { self.name.replace(name.into()); self } pub fn mount(mut self, mount_point: DockerMountPoint) -> Self { self.mount_points.push(mount_point); self } pub fn remove_after_run(mut self) -> Self { self.remove_after_run = t...
name
identifier_name
TestAtanh.rs
/* * Copyright (C) 2016 The Android Open Source Project * * 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 app...
float3 __attribute__((kernel)) testAtanhFloat3Float3(float3 inV) { return atanh(inV); } float4 __attribute__((kernel)) testAtanhFloat4Float4(float4 inV) { return atanh(inV); } half __attribute__((kernel)) testAtanhHalfHalf(half inV) { return atanh(inV); } half2 __attribute__((kernel)) testAtanhHalf2Half...
} float2 __attribute__((kernel)) testAtanhFloat2Float2(float2 inV) { return atanh(inV); }
random_line_split