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
serviceworkercontainer.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 crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions; use crate::dom::b...
} #[allow(unrooted_must_root)] // https://w3c.github.io/ServiceWorker/#service-worker-container-register-method and - A // https://w3c.github.io/ServiceWorker/#start-register-algorithm - B fn Register(&self, script_url: USVString, options: &RegistrationOptions) -> Rc<Promise> { // A: Step 1...
random_line_split
serviceworkercontainer.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 crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions; use crate::dom::b...
#[allow(unrooted_must_root)] // https://w3c.github.io/ServiceWorker/#service-worker-container-register-method and - A // https://w3c.github.io/ServiceWorker/#start-register-algorithm - B fn Register(&self, script_url: USVString, options: &RegistrationOptions) -> Rc<Promise> { // A: Step 1 ...
{ self.client.get_controller() }
identifier_body
serviceworkercontainer.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 crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions; use crate::dom::b...
{ eventtarget: EventTarget, controller: MutNullableDom<ServiceWorker>, client: Dom<Client>, } impl ServiceWorkerContainer { fn new_inherited(client: &Client) -> ServiceWorkerContainer { ServiceWorkerContainer { eventtarget: EventTarget::new_inherited(), controller: Defa...
ServiceWorkerContainer
identifier_name
serviceworkercontainer.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 crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions; use crate::dom::b...
, } // B: Step 3 if script_url.path().to_ascii_lowercase().contains("%2f") || script_url.path().to_ascii_lowercase().contains("%5c") { promise.reject_error(Error::Type( "Script URL contains forbidden characters".to_owned(), )); ...
{ promise.reject_error(Error::Type("Only secure origins are allowed".to_owned())); return promise; }
conditional_block
fact.rs
#[allow(non_snake_case)] #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct ExprItem { pub data: Option<String>, // pub type: Option<String>, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct FactcContent { pub expr: Option<Vec<ExprItem>>, } #[derive(RustcDecodable, RustcEnc...
#[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct Fact { pub fact: FactBody, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct ObjectsFactBody { pub paging: super::MetadataPaging, pub items: Vec<Fact>, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct...
pub meta: super::MetadataMeta, }
random_line_split
fact.rs
#[allow(non_snake_case)] #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct ExprItem { pub data: Option<String>, // pub type: Option<String>, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct
{ pub expr: Option<Vec<ExprItem>>, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct FactBody { pub content: FactcContent, pub meta: super::MetadataMeta, } #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] pub struct Fact { pub fact: FactBody, } #[derive(RustcDecodable, Rust...
FactcContent
identifier_name
celleditable.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...
fn remove_widget(&self) { unsafe { ffi::gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE(self.get_widget())) } } }
{ unsafe { ffi::gtk_cell_editable_editing_done(GTK_CELL_EDITABLE(self.get_widget())) } }
identifier_body
celleditable.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...
// along with rgtk. If not, see <http://www.gnu.org/licenses/>. //! Interface for widgets which can are used for editing cells use gtk::{mod, ffi}; use gtk::cast::GTK_CELL_EDITABLE; pub trait CellEditableTrait : gtk::WidgetTrait { fn editing_done(&self) { unsafe { ffi::gtk_cell_editable_editing_done(GTK...
random_line_split
celleditable.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...
(&self) { unsafe { ffi::gtk_cell_editable_remove_widget(GTK_CELL_EDITABLE(self.get_widget())) } } }
remove_widget
identifier_name
newweave.rs
//! Writer for new weaves use std::{ collections::BTreeMap, fs::rename, io::{self, Write}, mem::replace, }; use crate::{header::Header, Error, NamingConvention, Result, WriterInfo}; #[allow(unused)] use crate::Compression; /// A builder for a new weave file. The data should be written as a writer. ...
(mut self) -> Result<()> { let temp = replace(&mut self.temp, None); let name = match temp { Some(mut wi) => { writeln!(&mut wi.writer, "\x01E 1")?; wi.name } None => return Err(Error::AlreadyClosed), }; let _ = rename(s...
close
identifier_name
newweave.rs
//! Writer for new weaves use std::{ collections::BTreeMap, fs::rename, io::{self, Write}, mem::replace, }; use crate::{header::Header, Error, NamingConvention, Result, WriterInfo}; #[allow(unused)] use crate::Compression; /// A builder for a new weave file. The data should be written as a writer. ...
let mut header: Header = Default::default(); let delta = header.add(ntags)?; header.write(&mut writeinfo.writer)?; writeln!(&mut writeinfo.writer, "\x01I {}", delta)?; Ok(NewWeave { naming: nc, temp: Some(writeinfo), }) } pub fn close(mut...
random_line_split
newweave.rs
//! Writer for new weaves use std::{ collections::BTreeMap, fs::rename, io::{self, Write}, mem::replace, }; use crate::{header::Header, Error, NamingConvention, Result, WriterInfo}; #[allow(unused)] use crate::Compression; /// A builder for a new weave file. The data should be written as a writer. ...
None => return Err(Error::AlreadyClosed), }; let _ = rename(self.naming.main_file(), self.naming.backup_file()); rename(name, self.naming.main_file())?; Ok(()) } } impl<'n> Write for NewWeave<'n> { // Write the data out, just passing it through to the underlying fil...
{ writeln!(&mut wi.writer, "\x01E 1")?; wi.name }
conditional_block
newweave.rs
//! Writer for new weaves use std::{ collections::BTreeMap, fs::rename, io::{self, Write}, mem::replace, }; use crate::{header::Header, Error, NamingConvention, Result, WriterInfo}; #[allow(unused)] use crate::Compression; /// A builder for a new weave file. The data should be written as a writer. ...
pub fn close(mut self) -> Result<()> { let temp = replace(&mut self.temp, None); let name = match temp { Some(mut wi) => { writeln!(&mut wi.writer, "\x01E 1")?; wi.name } None => return Err(Error::AlreadyClosed), }; ...
{ let mut writeinfo = nc.new_temp()?; let mut ntags = BTreeMap::new(); for (k, v) in tags { ntags.insert(k.to_owned(), v.to_owned()); } let mut header: Header = Default::default(); let delta = header.add(ntags)?; header.write(&mut writeinfo.writer)?; ...
identifier_body
tests.rs
use crate::direct_transport::{DirectTransport, DirectTransportOptions}; use crate::router::{Router, RouterOptions}; use crate::transport::Transport; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; use std::env; async fn init() -> (Router, DirectTransport) { { ...
let _ = builder.is_test(true).try_init(); } let worker_manager = WorkerManager::new(); let worker = worker_manager .create_worker(WorkerSettings::default()) .await .expect("Failed to create worker"); let router = worker .create_router(RouterOptions::default()) ...
{ builder.filter_level(log::LevelFilter::Off); }
conditional_block
tests.rs
use crate::direct_transport::{DirectTransport, DirectTransportOptions}; use crate::router::{Router, RouterOptions}; use crate::transport::Transport; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; use std::env; async fn init() -> (Router, DirectTransport) { { ...
#[test] fn router_close_event() { future::block_on(async move { let (router, transport) = init().await; let (mut close_tx, close_rx) = async_oneshot::oneshot::<()>(); let _handler = transport.on_close(Box::new(move || { let _ = close_tx.send(()); })); let (mut ...
}
random_line_split
tests.rs
use crate::direct_transport::{DirectTransport, DirectTransportOptions}; use crate::router::{Router, RouterOptions}; use crate::transport::Transport; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; use std::env; async fn
() -> (Router, DirectTransport) { { let mut builder = env_logger::builder(); if env::var(env_logger::DEFAULT_FILTER_ENV).is_err() { builder.filter_level(log::LevelFilter::Off); } let _ = builder.is_test(true).try_init(); } let worker_manager = WorkerManager::new(...
init
identifier_name
tests.rs
use crate::direct_transport::{DirectTransport, DirectTransportOptions}; use crate::router::{Router, RouterOptions}; use crate::transport::Transport; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; use std::env; async fn init() -> (Router, DirectTransport)
let transport = router .create_direct_transport(DirectTransportOptions::default()) .await .expect("Failed to create transport1"); (router, transport) } #[test] fn router_close_event() { future::block_on(async move { let (router, transport) = init().await; let (mut c...
{ { let mut builder = env_logger::builder(); if env::var(env_logger::DEFAULT_FILTER_ENV).is_err() { builder.filter_level(log::LevelFilter::Off); } let _ = builder.is_test(true).try_init(); } let worker_manager = WorkerManager::new(); let worker = worker_mana...
identifier_body
htmlimageelement.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 dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLImageElementBinding; use dom::bindings::codege...
(self, width: u32) { let elem: JSRef<Element> = ElementCast::from_ref(self); elem.set_uint_attribute(&atom!("width"), width) } fn Height(self) -> u32 { let node: JSRef<Node> = NodeCast::from_ref(self); let rect = node.get_bounding_content_box(); to_px(rect.size.height) a...
SetWidth
identifier_name
htmlimageelement.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 dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLImageElementBinding; use dom::bindings::codege...
fn Width(self) -> u32 { let node: JSRef<Node> = NodeCast::from_ref(self); let rect = node.get_bounding_content_box(); to_px(rect.size.width) as u32 } fn SetWidth(self, width: u32) { let elem: JSRef<Element> = ElementCast::from_ref(self); elem.set_uint_attribute(&at...
{ let element: JSRef<Element> = ElementCast::from_ref(self); element.set_string_attribute(&atom!("ismap"), is_map.to_string()) }
identifier_body
htmlimageelement.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 dom::attr::AttrValue; use dom::bindings::codegen::Bindings::HTMLImageElementBinding; use dom::bindings::codege...
fn before_remove_attr(&self, name: &Atom, value: DOMString) { match self.super_type() { Some(ref s) => s.before_remove_attr(name, value.clone()), _ => (), } if atom!("src") == *name { self.update_image(None); } } fn parse_plain_attribute(...
self.update_image(Some((value, &url))); } }
random_line_split
net.rs
use {io}; use sys::unix::{nix, Io}; use std::os::unix::io::{AsRawFd, RawFd, FromRawFd}; pub use net::tcp::Shutdown; pub fn socket(family: nix::AddressFamily, ty: nix::SockType, nonblock: bool) -> io::Result<RawFd> { let opts = if nonblock { nix::SOCK_NONBLOCK | nix::SOCK_CLOEXEC } else { nix::S...
pub fn bind(io: &Io, addr: &nix::SockAddr) -> io::Result<()> { nix::bind(io.as_raw_fd(), addr) .map_err(super::from_nix_error) } pub fn listen(io: &Io, backlog: usize) -> io::Result<()> { nix::listen(io.as_raw_fd(), backlog) .map_err(super::from_nix_error) } pub fn accept(io: &Io, nonblock: bo...
{ match nix::connect(io.as_raw_fd(), addr) { Ok(_) => Ok(true), Err(e) => { match e { nix::Error::Sys(nix::EINPROGRESS) => Ok(false), _ => Err(super::from_nix_error(e)) } } } }
identifier_body
net.rs
use {io}; use sys::unix::{nix, Io}; use std::os::unix::io::{AsRawFd, RawFd, FromRawFd}; pub use net::tcp::Shutdown; pub fn socket(family: nix::AddressFamily, ty: nix::SockType, nonblock: bool) -> io::Result<RawFd> { let opts = if nonblock { nix::SOCK_NONBLOCK | nix::SOCK_CLOEXEC } else { nix::S...
(io: &Io, addr: &nix::SockAddr) -> io::Result<bool> { match nix::connect(io.as_raw_fd(), addr) { Ok(_) => Ok(true), Err(e) => { match e { nix::Error::Sys(nix::EINPROGRESS) => Ok(false), _ => Err(super::from_nix_error(e)) } } } } pu...
connect
identifier_name
net.rs
use {io}; use sys::unix::{nix, Io}; use std::os::unix::io::{AsRawFd, RawFd, FromRawFd}; pub use net::tcp::Shutdown; pub fn socket(family: nix::AddressFamily, ty: nix::SockType, nonblock: bool) -> io::Result<RawFd> { let opts = if nonblock { nix::SOCK_NONBLOCK | nix::SOCK_CLOEXEC
nix::SOCK_CLOEXEC }; nix::socket(family, ty, opts, 0) .map_err(super::from_nix_error) } pub fn connect(io: &Io, addr: &nix::SockAddr) -> io::Result<bool> { match nix::connect(io.as_raw_fd(), addr) { Ok(_) => Ok(true), Err(e) => { match e { nix::Er...
} else {
random_line_split
binary.rs
// Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license //! Monte-Carlo simulation of a binary mixture of H20 and CO2. extern crate lumol; extern crate lumol_input as input; use lumol::Logger; use lumol::sys::{Molecule, Particle, Trajectory, UnitCell}; use lum...
{ Logger::stdout(); let mut system = Trajectory::open("data/binary.xyz") .and_then(|mut traj| traj.read()) .unwrap(); // Add bonds in the system for i in 0..system.molecules().len() / 3 { system.add_bond(3 * i, 3 * i + 1); ...
in()
identifier_name
binary.rs
// Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license //! Monte-Carlo simulation of a binary mixture of H20 and CO2. extern crate lumol; extern crate lumol_input as input; use lumol::Logger; use lumol::sys::{Molecule, Particle, Trajectory, UnitCell}; use lum...
let h2o = { // Or define a new molecule by hand let mut molecule = Molecule::new(0); molecule.merge_with(Molecule::new(1)); molecule.merge_with(Molecule::new(2)); molecule.add_bond(0, 1); molecule.add_bond(1, 2); molecule_type(&molecule, &[Particle::new("H")...
Logger::stdout(); let mut system = Trajectory::open("data/binary.xyz") .and_then(|mut traj| traj.read()) .unwrap(); // Add bonds in the system for i in 0..system.molecules().len() / 3 { system.add_bond(3 * i, 3 * i + 1); ...
identifier_body
binary.rs
// Lumol, an extensible molecular simulation engine // Copyright (C) 2015-2016 Lumol's contributors — BSD license //! Monte-Carlo simulation of a binary mixture of H20 and CO2. extern crate lumol; extern crate lumol_input as input; use lumol::Logger; use lumol::sys::{Molecule, Particle, Trajectory, UnitCell}; use lum...
use input::InteractionsInput; fn main() { Logger::stdout(); let mut system = Trajectory::open("data/binary.xyz") .and_then(|mut traj| traj.read()) .unwrap(); // Add bonds in the system for i in 0..system.molecules().len() / 3 { syst...
random_line_split
parser.rs
use std::str::from_utf8; use std::result::Result; use nom::*; /* * Core structs */ #[derive(Debug,PartialEq,Eq)] pub struct TarEntry<'a> { pub header: PosixHeader<'a>, pub contents: &'a [u8] } #[derive(Debug,PartialEq,Eq)] pub struct PosixHeader<'a> { pub name: &'a str, pub mode: &'a str,...
(i: &[u8]) -> IResult<&[u8], UStarExtraHeader> { chain!(i, prefix: parse_str155 ~ take!(12), ||{ UStarExtraHeader::PosixUStar(PosixUStarHeader { prefix: prefix }) } ) } fn parse_ustar00_extra<'a, 'b>(i: &'a [u8], flag: &'b TypeFlag) -> IRe...
parse_ustar00_extra_posix
identifier_name
parser.rs
use std::str::from_utf8; use std::result::Result; use nom::*; /* * Core structs */ #[derive(Debug,PartialEq,Eq)] pub struct TarEntry<'a> { pub header: PosixHeader<'a>, pub contents: &'a [u8] } #[derive(Debug,PartialEq,Eq)] pub struct PosixHeader<'a> { pub name: &'a str, pub mode: &'a str,...
pub magic: &'a str, pub version: &'a str, pub uname: &'a str, pub gname: &'a str, pub devmajor: u64, pub devminor: u64, pub extra: UStarExtraHeader<'a> } #[derive(Debug,PartialEq,Eq)] pub enum UStarExtraHeader<'a> { PosixUStar(PosixUStarHeader<'a>), Pax(PaxHeader<'a>) }...
#[derive(Debug,PartialEq,Eq)] pub struct UStarHeader<'a> {
random_line_split
parser.rs
use std::str::from_utf8; use std::result::Result; use nom::*; /* * Core structs */ #[derive(Debug,PartialEq,Eq)] pub struct TarEntry<'a> { pub header: PosixHeader<'a>, pub contents: &'a [u8] } #[derive(Debug,PartialEq,Eq)] pub struct PosixHeader<'a> { pub name: &'a str, pub mode: &'a str,...
fn parse_ustar00<'a, 'b>(i: &'a [u8], flag: &'b TypeFlag) -> IResult<&'a [u8], ExtraHeader<'a>> { chain!(i, tag!("00") ~ uname: parse_str32 ~ gname: parse_str32 ~ devmajor: parse_octal8 ~ devminor: parse_octal8 ~ extra: apply!(parse_ustar00_ex...
{ match *flag { TypeFlag::PaxInterexchangeFormat => { chain!(i, mut header: parse_ustar00_extra_pax ~ apply!(parse_pax_extra_sparses, &mut header), ||{ UStarExtraHeader::Pax(header) } ) }, ...
identifier_body
main.rs
fn main() { let mut ss = String::from("hello"); ss.push_str(", world!"); println!("{}", ss); // using the clone method the memory on heap for s1 is copied // for s2. This operation can be expensive in some cases. let s1 = String::from("hello"); let s2 = s1.clone(); println!("s1 = {}, ...
println!("x = {}, y = {}", x, y); // List of types that accept the Copy trait. // All the integer types, like u32. // The boolean type, bool, with values true and false. // All the floating point types, like f64. // Tuples, but only if they contain types that are also Copy. (i32, i32) // i...
// There is no difference between deep and shallow copying here. let x = 5; let y = x;
random_line_split
main.rs
fn main() { let mut ss = String::from("hello"); ss.push_str(", world!"); println!("{}", ss); // using the clone method the memory on heap for s1 is copied // for s2. This operation can be expensive in some cases. let s1 = String::from("hello"); let s2 = s1.clone(); println!("s1 = {}, ...
: String) -> (String, usize) { let length = s.len(); // len() returns the length of a String. (s, length) } fn takes_ownership(some_string: String) { // some_string comes into scope. println!("{}", some_string); } // Here, some_string goes out of scope and `drop` is called. The backing // memory is ...
lculate_length(s
identifier_name
main.rs
fn main()
// List of types that accept the Copy trait. // All the integer types, like u32. // The boolean type, bool, with values true and false. // All the floating point types, like f64. // Tuples, but only if they contain types that are also Copy. (i32, i32) // is Copy, but (i32, String) is not. ...
{ let mut ss = String::from("hello"); ss.push_str(", world!"); println!("{}", ss); // using the clone method the memory on heap for s1 is copied // for s2. This operation can be expensive in some cases. let s1 = String::from("hello"); let s2 = s1.clone(); println!("s1 = {}, s2 = {}", ...
identifier_body
tests.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 quickcheck::quickcheck; use crate::Bytes; use crate::Text; quickcheck! { fn test_shallow_clone(v: Vec<u8>) -> bool { let ...
Text = SAMPLE_TEXT.into(); let b = a.slice(3..12); let s: &str = b.as_ref(); let c = a.slice_to_bytes(s); let d = b.slice_to_bytes(s); assert_eq!(b.as_ptr(), c.as_ptr()); assert_eq!(b.as_ptr(), d.as_ptr()); } #[test] fn test_text_to_string() { let a: Text = SAMPLE_TEXT.into(); assert_eq...
valid() { let a:
identifier_name
tests.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 quickcheck::quickcheck; use crate::Bytes; use crate::Text; quickcheck! { fn test_shallow_clone(v: Vec<u8>) -> bool { let ...
t_text_to_string() { let a: Text = SAMPLE_TEXT.into(); assert_eq!(a.to_string(), SAMPLE_TEXT.to_string()); } #[test] #[should_panic] fn test_text_slice_invalid() { let a: Text = SAMPLE_TEXT.into(); let _b = a.slice(3..11); // invalid utf-8 boundary } #[test] fn test_downcast_mut() { let v = b"abcd...
t = SAMPLE_TEXT.into(); let b = a.slice(3..12); let s: &str = b.as_ref(); let c = a.slice_to_bytes(s); let d = b.slice_to_bytes(s); assert_eq!(b.as_ptr(), c.as_ptr()); assert_eq!(b.as_ptr(), d.as_ptr()); } #[test] fn tes
identifier_body
pass-by-copy.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 a = A {a: box(GC) 10}; let b = box(GC) 10; magic(a); magic(A {a: box(GC) 20}); magic2(b); magic2(box(GC) 20); }
identifier_body
pass-by-copy.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 ...
pub fn main() { let a = A {a: box(GC) 10}; let b = box(GC) 10; magic(a); magic(A {a: box(GC) 20}); magic2(b); magic2(box(GC) 20); }
fn magic2(x: Gc<int>) { println!("{:?}", x); } struct A { a: Gc<int> }
random_line_split
pass-by-copy.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: A) { println!("{:?}", x); } fn magic2(x: Gc<int>) { println!("{:?}", x); } struct A { a: Gc<int> } pub fn main() { let a = A {a: box(GC) 10}; let b = box(GC) 10; magic(a); magic(A {a: box(GC) 20}); magic2(b); magic2(box(GC) 20); }
magic
identifier_name
regions-early-bound-used-in-bound-method.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_eq!(b1.add(b1), 6); }
random_line_split
regions-early-bound-used-in-bound-method.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 ...
} pub fn main() { let b1 = Box { t: &3 }; assert_eq!(b1.add(b1), 6); }
{ *self.t + *g2.get() }
identifier_body
regions-early-bound-used-in-bound-method.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) -> &'a isize { self.t } } impl<'a> Box<'a> { fn add<'b,G:GetRef<'b>>(&self, g2: G) -> isize { *self.t + *g2.get() } } pub fn main() { let b1 = Box { t: &3 }; assert_eq!(b1.add(b1), 6); }
get
identifier_name
armv7_unknown_linux_musleabihf.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 ...
features: "+v7,+vfp3,+d16,+thumb2,-neon".to_string(), cpu: "generic".to_string(), max_atomic_width: Some(64), abi_blacklist: super::arm_base::abi_blacklist(), .. base } }) }
{ let base = super::linux_musl_base::opts(); Ok(Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM // doesn't support the "musleabihf" value. llvm_target: "armv7-unknown-linux-gnueab...
identifier_body
armv7_unknown_linux_musleabihf.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 ...
() -> TargetResult { let base = super::linux_musl_base::opts(); Ok(Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM // doesn't support the "musleabihf" value. llvm_target: "armv7-u...
target
identifier_name
armv7_unknown_linux_musleabihf.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 ...
Ok(Target { // It's important we use "gnueabihf" and not "musleabihf" here. LLVM // uses it to determine the calling convention and float ABI, and LLVM // doesn't support the "musleabihf" value. llvm_target: "armv7-unknown-linux-gnueabihf".to_string(), target_endian: "little"...
let base = super::linux_musl_base::opts();
random_line_split
metadata.rs
// Copyright 2016 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
#[cfg(test)] mod tests { use ffi::mutable_data::metadata::mdata_encode_metadata; use ffi_utils::test_utils::call_vec_u8; use maidsafe_utilities::serialisation::deserialise; use safe_core::ipc::resp::UserMetadata; // Test serializing and deserializing metadata. #[test] fn serialize_metadat...
{ catch_unwind_cb(user_data, o_cb, || -> Result<_, AppError> { let metadata = UserMetadata::clone_from_repr_c(metadata)?; let encoded = serialise(&metadata)?; o_cb(user_data, FFI_RESULT_OK, encoded.as_ptr(), encoded.len()); Ok(()) }) }
identifier_body
metadata.rs
// Copyright 2016 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
}
}
random_line_split
metadata.rs
// Copyright 2016 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License, // version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which // licence you accepted on initial access to the Software (the "Licences"). // // By ...
() { let metadata1 = UserMetadata { name: None, description: Some(String::from("test")), }; let metadata_resp = match metadata1.clone().into_md_response(Default::default(), 0) { Ok(val) => val, _ => panic!("An error occurred"), }; ...
serialize_metadata
identifier_name
step.rs
// step.rs extern crate noise; extern crate image; extern crate time; use noise::gen::NoiseGen; use noise::gen::fbm::FBM; use noise::utils::step; use image::GenericImage; use std::io::File; use time::precise_time_s; fn
() { let mut ngen = FBM::new_rand(24, 0.5, 2.5, 175.0); let steps: &[f64] = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]; println!("Noise seed is {}", ngen.get_seed()); let img_size = 512 as u32; let mut imbuf = image::ImageBuf::new(img_size, img_size); let start = precise_time_s(); for x in range(...
main
identifier_name
step.rs
// step.rs extern crate noise; extern crate image; extern crate time; use noise::gen::NoiseGen; use noise::gen::fbm::FBM; use noise::utils::step; use image::GenericImage; use std::io::File; use time::precise_time_s; fn main()
} let end = precise_time_s(); let fout = File::create(&Path::new("step.png")).unwrap(); let _ = image::ImageLuma8(imbuf).save(fout, image::PNG); println!("step.png saved"); println!("generated {} points in {} ms", img_size*img_size, (end-start)*1000.0); }
{ let mut ngen = FBM::new_rand(24, 0.5, 2.5, 175.0); let steps: &[f64] = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]; println!("Noise seed is {}", ngen.get_seed()); let img_size = 512 as u32; let mut imbuf = image::ImageBuf::new(img_size, img_size); let start = precise_time_s(); for x in range(0, ...
identifier_body
step.rs
// step.rs extern crate noise; extern crate image; extern crate time; use noise::gen::NoiseGen; use noise::gen::fbm::FBM; use noise::utils::step; use image::GenericImage; use std::io::File; use time::precise_time_s; fn main() { let mut ngen = FBM::new_rand(24, 0.5, 2.5, 175.0); let steps: &[f64] = [0.0, 0.2,...
println!("Noise seed is {}", ngen.get_seed()); let img_size = 512 as u32; let mut imbuf = image::ImageBuf::new(img_size, img_size); let start = precise_time_s(); for x in range(0, img_size) { for y in range(0, img_size) { let xx = x as f64; let yy = y as f64; ...
random_line_split
sort_an_array_of_composites.rs
// http://rosettacode.org/wiki/Sort_an_array_of_composite_structures #[derive(Debug, PartialEq)] pub struct Element { name: String, value: String, } impl Element { fn new(name: &str, value: &str) -> Element { Element { name: name.to_string(), value: value.to_string(), ...
Element::new("Cobalt", "Co"), Element::new("Copper", "Cu"), Element::new("Iron", "Fe"), Element::new("Nickel", "Ni"), Element::new("Zinc", "Zn"), ]); } }
]; sort_by_name(&mut values); assert_eq!(values, vec![
random_line_split
sort_an_array_of_composites.rs
// http://rosettacode.org/wiki/Sort_an_array_of_composite_structures #[derive(Debug, PartialEq)] pub struct Element { name: String, value: String, } impl Element { fn new(name: &str, value: &str) -> Element { Element { name: name.to_string(), value: value.to_string(), ...
() { let mut values = vec![ Element::new("Iron", "Fe"), Element::new("Cobalt", "Co"), Element::new("Nickel", "Ni"), Element::new("Copper", "Cu"), Element::new("Zinc", "Zn"), ]; sort_by_name(&mut values); println!("{:?}", values); } #[cfg(test)] mod tests { us...
main
identifier_name
adapter.rs
extern crate dotalittlehelper; use dotalittlehelper::*; #[test] fn read_json_configuration() { let json_str = r#"{ "entities": [{ "identity": {"id": "test", "name": "Test"}, "entity_type": "Hero", "attributes": [{ "identity": {"id": "test_attr", "name": ...
{ let json_str = r#"{ "entitties": [{ "what": "is this" }] }"#; let test_entities = adapter::read_json_configuration(json_str); assert_eq!(0, test_entities.len()); let json_str = r#"{ "entities": [{ "identity": {"id": "test", "name": "Test"} ...
identifier_body
adapter.rs
extern crate dotalittlehelper; use dotalittlehelper::*; #[test] fn read_json_configuration() { let json_str = r#"{ "entities": [{ "identity": {"id": "test", "name": "Test"}, "entity_type": "Hero", "attributes": [{ "identity": {"id": "test_attr", "name": ...
String::from("test_attr"), String::from("Test Attr") ), 9001 ) ) ); assert_eq!(real_entity, test_entity); } #[test] #[should_panic] fn read_json_configuration_fail() { let json_str = r#"{ "entitties": [{ "what": "is...
entity::Attribute::new( entity::Identity::new(
random_line_split
adapter.rs
extern crate dotalittlehelper; use dotalittlehelper::*; #[test] fn
() { let json_str = r#"{ "entities": [{ "identity": {"id": "test", "name": "Test"}, "entity_type": "Hero", "attributes": [{ "identity": {"id": "test_attr", "name": "Test Attr"}, "value": 9001 }] }] }"#; let test_...
read_json_configuration
identifier_name
attributes.rs
use model; type Attribute = model::Attribute; type Param = model::Parameter;
attribute_type:String::new(), is_array:false, params:Vec::new(), }; let p = Param { name:"param1".to_string(), value:"param1val".to_string(), }; t.params.push(Box::new(p)); assert!(t.is_param_present("param1")); assert!(!t.is_param_present("param2")); } #[test] fn test_is_param_value...
#[test] fn test_is_param_present() { let mut t = Attribute { name:String::new(),
random_line_split
attributes.rs
use model; type Attribute = model::Attribute; type Param = model::Parameter; #[test] fn test_is_param_present() { let mut t = Attribute { name:String::new(), attribute_type:String::new(), is_array:false, params:Vec::new(), }; let p = Param { name:"param1".to_string(), value:"param1val"....
{ let mut t = Attribute { name:String::new(), attribute_type:String::new(), is_array:false, params:Vec::new(), }; let p = Param { name:"param1".to_string(), value:"param1val".to_string(), }; t.params.push(Box::new(p)); assert!(t.is_param_value_present("param1", "param1val")); as...
identifier_body
attributes.rs
use model; type Attribute = model::Attribute; type Param = model::Parameter; #[test] fn
() { let mut t = Attribute { name:String::new(), attribute_type:String::new(), is_array:false, params:Vec::new(), }; let p = Param { name:"param1".to_string(), value:"param1val".to_string(), }; t.params.push(Box::new(p)); assert!(t.is_param_present("param1")); assert!(!t.is_para...
test_is_param_present
identifier_name
closure-in-generic-function.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.
// except according to those terms. // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info // debugger:rbreak zzz // debugger:run // debugger:finish // debugger:print x // check:$1 = 0.5 // debugger:print y // check:$2 = 10 // debugger:continue // debugger:finish // debugger:print *x // check:$3 = 29 ...
// // 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
closure-in-generic-function.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 ...
<T1, T2>(a: T1, b: T2) -> (T2, T1) { let closure = |x, y| { zzz(); (y, x) }; closure(a, b) } fn main() { some_generic_fun(0.5, 10); some_generic_fun(&29, ~110); } fn zzz() {()}
some_generic_fun
identifier_name
closure-in-generic-function.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 ...
fn main() { some_generic_fun(0.5, 10); some_generic_fun(&29, ~110); } fn zzz() {()}
{ let closure = |x, y| { zzz(); (y, x) }; closure(a, b) }
identifier_body
token.rs
// This program is subject to the terms of the GNU General Public // License, version 2.0. If a copy of the GPL was not distributed with // this program, You can obtain one at http://gnu.org. use std::fmt::{Debug, Write}; use interner::{Interned}; use span::{Spanned}; /// A token with a span. pub type SToken = Spann...
(self) -> bool { match self { Token::StringPart(..) => true, Token::String(..) => true, Token::Integer(..) => true, Token::Ident(..) => true, Token::True => true, Token::False => true, Token::Null ...
starts_expr
identifier_name
token.rs
// This program is subject to the terms of the GNU General Public // License, version 2.0. If a copy of the GPL was not distributed with // this program, You can obtain one at http://gnu.org. use std::fmt::{Debug, Write}; use interner::{Interned}; use span::{Spanned}; /// A token with a span. pub type SToken = Spann...
Token::Concat => false, Token::Plus => false, Token::Times => false, Token::Div => false, Token::Mod => false, Token::Overlay => false, Token::AndAnd => false, Token::OrOr ...
Token::Unequal => false, Token::Lt => false, Token::Le => false, Token::Gt => false, Token::Ge => false,
random_line_split
into_searcher.rs
#![feature(core)]
mod tests { use core::str::pattern::Searcher; use core::str::pattern::SearchStep::{Match, Reject, Done}; use core::str::pattern::StrSearcher; use core::str::pattern::Pattern; // #[derive(Copy, Clone, Eq, PartialEq, Debug)] // pub enum SearchStep { // /// Expresses that a match of the pa...
extern crate core; #[cfg(test)]
random_line_split
into_searcher.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::str::pattern::Searcher; use core::str::pattern::SearchStep::{Match, Reject, Done}; use core::str::pattern::StrSearcher; use core::str::pattern::Pattern; // #[derive(Copy, Clone, Eq, PartialEq, Debug)] // pub enum SearchSte...
{ let string: &str = "玻璃"; let string_ptr: &&str = &string; let haystack: &str = "我能吞下玻璃而不傷身體。"; let mut searcher: StrSearcher = string_ptr.into_searcher(haystack); assert_eq!(searcher.next(), Reject(0, 3)); assert_eq!(searcher.next(), Reject(3, 6)); assert_eq!(searcher.next(), Reject(6, 9)); assert_eq!(search...
identifier_body
into_searcher.rs
#![feature(core)] extern crate core; #[cfg(test)] mod tests { use core::str::pattern::Searcher; use core::str::pattern::SearchStep::{Match, Reject, Done}; use core::str::pattern::StrSearcher; use core::str::pattern::Pattern; // #[derive(Copy, Clone, Eq, PartialEq, Debug)] // pub enum SearchSte...
() { let string: &str = "玻璃"; let string_ptr: &&str = &string; let haystack: &str = "我能吞下玻璃而不傷身體。"; let mut searcher: StrSearcher = string_ptr.into_searcher(haystack); assert_eq!(searcher.next(), Reject(0, 3)); assert_eq!(searcher.next(), Reject(3, 6)); assert_eq!(searcher.next(), Reject(6, 9)); assert_eq!(sea...
into_searcher_test1
identifier_name
hard-tabs.rs
// rustfmt-wrap_comments: true // rustfmt-hard_tabs: true fn main() { let x = Bar; let y = Foo { a: x }; Foo { a: foo(), // comment // comment b: bar(), ..something }; fn foo(a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, ...
* comment */ { } unsafe /* So this is a very long comment. * Multi-line, too. * Will it still format correctly? */ { } let chain = funktion_kall() .go_to_next_line_with_tab() .go_to_next_line_with_tab() .go_to_next_line_with_tab(); let z = [xxxxx...
} unsafe /* very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
random_line_split
hard-tabs.rs
// rustfmt-wrap_comments: true // rustfmt-hard_tabs: true fn main()
a: i32, a: i32, a: i32) { } let str = "AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAa"; if let (some_very_large, tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 { } if cond() { something(); ...
{ let x = Bar; let y = Foo { a: x }; Foo { a: foo(), // comment // comment b: bar(), ..something }; fn foo(a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32,
identifier_body
hard-tabs.rs
// rustfmt-wrap_comments: true // rustfmt-hard_tabs: true fn
() { let x = Bar; let y = Foo { a: x }; Foo { a: foo(), // comment // comment b: bar(), ..something }; fn foo(a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32) { } let str = "AAAAAAAA...
main
identifier_name
build.rs
fn
() { println!("cargo:rerun-if-changed=build.rs"); #[cfg(feature = "ispc")] { if std::env::var("CARGO_FEATURE_ISPC").is_ok() { let mut cfg = ispc::Config::new(); if cfg!(windows) { cfg.debug(false); } let ispc_files = vec!["volta/mand...
main
identifier_name
build.rs
fn main()
ispc::opt::TargetISA::SSE4i32x4, ispc::opt::TargetISA::AVX1i32x8, ispc::opt::TargetISA::AVX2i32x8, ispc::opt::TargetISA::AVX512KNLi32x16, ]); cfg.compile("mandelbrot"); } } }
{ println!("cargo:rerun-if-changed=build.rs"); #[cfg(feature = "ispc")] { if std::env::var("CARGO_FEATURE_ISPC").is_ok() { let mut cfg = ispc::Config::new(); if cfg!(windows) { cfg.debug(false); } let ispc_files = vec!["volta/mandelb...
identifier_body
build.rs
fn main() { println!("cargo:rerun-if-changed=build.rs"); #[cfg(feature = "ispc")] { if std::env::var("CARGO_FEATURE_ISPC").is_ok()
cfg.compile("mandelbrot"); } } }
{ let mut cfg = ispc::Config::new(); if cfg!(windows) { cfg.debug(false); } let ispc_files = vec!["volta/mandelbrot.ispc"]; for s in &ispc_files[..] { cfg.file(*s); } cfg.target_isas(vec![ ...
conditional_block
build.rs
fn main() { println!("cargo:rerun-if-changed=build.rs"); #[cfg(feature = "ispc")] { if std::env::var("CARGO_FEATURE_ISPC").is_ok() { let mut cfg = ispc::Config::new(); if cfg!(windows) { cfg.debug(false); } let ispc_files = vec!["vol...
cfg.compile("mandelbrot"); } } }
ispc::opt::TargetISA::AVX512KNLi32x16, ]);
random_line_split
dom.rs
pub fn id(&self) -> usize { self.0 } } /// Simple trait to provide basic information about the type of an element. /// /// We avoid exposing the full type id, since computing it in the general case /// would be difficult for Gecko nodes. pub trait NodeInfo { /// Whether this node is an element. ...
} None => return None, } } } } /// An iterator over the DOM children of a node. pub struct DomChildren<N>(Option<N>); impl<N> Iterator for DomChildren<N> where N: TNode { type Item = N; fn next(&mut self) -> Option<N> { match self.0.take() {...
{ return Some(n) }
conditional_block
dom.rs
) -> fmt::Result { fmt_with_data_and_primary_values(f, self.0) } } /// Wrapper to output the subtree rather than the single node when formatting /// for Debug. pub struct ShowSubtree<N: TNode>(pub N); impl<N: TNode> Debug for ShowSubtree<N> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ...
{ &self.0 }
identifier_body
dom.rs
) } } /// Wrapper to output the primary computed values along with the node when /// formatting for Debug. This is very verbose. pub struct ShowDataAndPrimaryValues<N: TNode>(pub N); impl<N: TNode> Debug for ShowDataAndPrimaryValues<N> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt_with_d...
new
identifier_name
dom.rs
set_can_be_fragmented(&self, value: bool); } /// Wrapper to output the ElementData along with the node when formatting for /// Debug. pub struct ShowData<N: TNode>(pub N); impl<N: TNode> Debug for ShowData<N> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt_with_data(f, self.0) } } /// Wr...
}
random_line_split
mod.rs
use protocol_derive::{Decode, Encode}; #[derive(Clone, PartialEq, Debug, Encode, Decode)] #[protocol(id = 161)] pub struct CharacterCreationResultMessage<'a> { pub result: u8, pub _phantom: std::marker::PhantomData<&'a ()>, } #[derive(Clone, PartialEq, Debug, Encode, Decode)] #[protocol(id = 5544)] pub struct...
<'a> { pub _phantom: std::marker::PhantomData<&'a ()>, } #[derive(Clone, PartialEq, Debug, Encode, Decode)] #[protocol(id = 164)] pub struct CharacterNameSuggestionFailureMessage<'a> { pub reason: u8, pub _phantom: std::marker::PhantomData<&'a ()>, } #[derive(Clone, PartialEq, Debug, Encode, Decode)] #[pr...
CharacterNameSuggestionRequestMessage
identifier_name
mod.rs
use protocol_derive::{Decode, Encode}; #[derive(Clone, PartialEq, Debug, Encode, Decode)] #[protocol(id = 161)] pub struct CharacterCreationResultMessage<'a> { pub result: u8, pub _phantom: std::marker::PhantomData<&'a ()>, } #[derive(Clone, PartialEq, Debug, Encode, Decode)] #[protocol(id = 5544)] pub struct...
#[derive(Clone, PartialEq, Debug, Encode, Decode)] #[protocol(id = 6733)] pub struct CharacterCanBeCreatedResultMessage<'a> { pub yes_you_can: bool, pub _phantom: std::marker::PhantomData<&'a ()>, } #[derive(Clone, PartialEq, Debug, Encode, Decode)] #[protocol(id = 6732)] pub struct CharacterCanBeCreatedReques...
pub reason: u8, pub _phantom: std::marker::PhantomData<&'a ()>, }
random_line_split
dep-graph-struct-signature.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 main() { } #[rustc_if_this_changed] struct WillChange { x: u32, y: u32 } struct WontChange { x: u32, y: u32 } // these are valid dependencies mod signatures { use WillChange; #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path #[rustc_then_this_would_need(AssociatedItems)] //...
#![allow(dead_code)] #![allow(unused_variables)]
random_line_split
dep-graph-struct-signature.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...
} struct WillChanges { #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK x: WillChange, #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK y: WillChange } // The fields change, not the type itself. #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no pat...
{ }
identifier_body
dep-graph-struct-signature.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...
{ x: u32, y: u32 } struct WontChange { x: u32, y: u32 } // these are valid dependencies mod signatures { use WillChange; #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path #[rustc_then_this_would_need(AssociatedItems)] //~ ERROR no path #[rustc_then_this_would_need(TraitDefO...
WillChange
identifier_name
mod.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/. */ /// /// Example cUrl request: /// curl -X PUT -d '[[[{"id":"setter:talk@link.mozilla.org"}], {"String": "hello wor...
<T> { talk_setter_id: Id<Channel>, engine: T } impl<T: TtsEngine> Adapter for TtsAdapter<T> { fn id(&self) -> Id<AdapterId> { adapter_id!(ADAPTER_ID) } fn name(&self) -> &str { ADAPTER_NAME } fn vendor(&self) -> &str { ADAPTER_VENDOR } fn version(&self) ->...
TtsAdapter
identifier_name
mod.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/. */ /// /// Example cUrl request: /// curl -X PUT -d '[[[{"id":"setter:talk@link.mozilla.org"}], {"String": "hello wor...
let talk_setter_id = Id::new("setter:talk@link.mozilla.org"); try!(adapt.add_adapter(Arc::new(TtsAdapter { talk_setter_id: talk_setter_id.clone(), engine: engine }))); let service_id = service_id!("espeak@link.mozilla.org"); let adapter_id = adapter_id!(ADAPTER_ID); try!(adapt....
{ warn!("eSpeak initialization failed!"); return Err(Error::InternalError(InternalError::GenericError("eSpeak initialization failed!".to_owned()))); }
conditional_block
mod.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/. */ /// /// Example cUrl request: /// curl -X PUT -d '[[[{"id":"setter:talk@link.mozilla.org"}], {"String": "hello wor...
}
random_line_split
mod.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/. */ /// /// Example cUrl request: /// curl -X PUT -d '[[[{"id":"setter:talk@link.mozilla.org"}], {"String": "hello wor...
fn vendor(&self) -> &str { ADAPTER_VENDOR } fn version(&self) -> &[u32;4] { &ADAPTER_VERSION } fn fetch_values(&self, mut set: Vec<Id<Channel>>, _: User) -> ResultMap<Id<Channel>, Option<Value>, Error> { set.drain(..).map(|id| { (id.clone(), Err(Error::Interna...
{ ADAPTER_NAME }
identifier_body
lib.rs
#[macro_use] extern crate winreg; #[macro_use] extern crate rustler; #[macro_use] extern crate rustler_codegen; #[macro_use] extern crate lazy_static; use rustler::{NifEnv, NifTerm, NifResult, NifEncoder}; use winreg::RegKey; use winreg::enums::*; mod atoms { rustler_atoms! { atom ok; //atom erro...
<'a>(env: NifEnv<'a>, args: &[NifTerm<'a>]) -> NifResult<NifTerm<'a>> { let hklm = RegKey::predef(HKEY_LOCAL_MACHINE); let file_system_key = hklm.open_subkey_with_flags("SYSTEM\\CurrentControlSet\\Control\\FileSystem", KEY_READ).unwrap(); let eight_dot_three_disabled: u32 = file_system_key.get_value("NtfsDi...
check_short_names
identifier_name
lib.rs
#[macro_use] extern crate winreg; #[macro_use] extern crate rustler; #[macro_use] extern crate rustler_codegen; #[macro_use] extern crate lazy_static; use rustler::{NifEnv, NifTerm, NifResult, NifEncoder}; use winreg::RegKey; use winreg::enums::*; mod atoms { rustler_atoms! { atom ok; //atom erro...
fn check_short_names<'a>(env: NifEnv<'a>, args: &[NifTerm<'a>]) -> NifResult<NifTerm<'a>> { let hklm = RegKey::predef(HKEY_LOCAL_MACHINE); let file_system_key = hklm.open_subkey_with_flags("SYSTEM\\CurrentControlSet\\Control\\FileSystem", KEY_READ).unwrap(); let eight_dot_three_disabled: u32 = file_system...
{ let num1: i64 = try!(args[0].decode()); let num2: i64 = try!(args[1].decode()); Ok((atoms::ok(), num1 + num2).encode(env)) }
identifier_body
lib.rs
#[macro_use] extern crate winreg; #[macro_use] extern crate rustler; #[macro_use] extern crate rustler_codegen; #[macro_use] extern crate lazy_static; use rustler::{NifEnv, NifTerm, NifResult, NifEncoder}; use winreg::RegKey; use winreg::enums::*; mod atoms { rustler_atoms! { atom ok; //atom erro...
atom ntfs_create_short_names = "ntfs_create_short_names"; atom ntfs_never_create_short_names = "ntfs_never_create_short_names"; atom ntfs_create_short_per_volume = "ntfs_create_short_per_volume"; atom ntfs_create_short_only_on_system_volume = "ntfs_create_short_only_on_system_volume"; ...
// atom __false__ = "false";
random_line_split
lib.rs
//! # The rusty-machine crate. //! //! A crate built for machine learning that works out-of-the-box. //! //! --- //! //! ## Structure //! //! The crate is made up of two primary modules: learning and linalg. //! //! ### learning //! //! The learning module contains all of the machine learning modules. //! This means th...
//! //! The linalg module reexports some structs and traits from the //! [rulinalg](https://crates.io/crates/rulinalg) crate. This is to provide //! easy access to common linear algebra tools within this library. //! //! --- //! //! ## Usage //! //! Specific usage of modules is described within the modules themselves. ...
//! ### linalg
random_line_split
util.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 struct Stderr; impl io::Writer for Stderr { fn write(&mut self, data: &[u8]) -> IoResult<()> { unsafe { libc::write(libc::STDERR_FILENO, data.as_ptr() as *libc::c_void, data.len() as libc::size_t); } Ok(()) // yes, we're lyin...
{ match os::getenv("RUST_THREADS") { Some(nstr) => { let opt_n: Option<uint> = FromStr::from_str(nstr); match opt_n { Some(n) if n > 0 => n, _ => rtabort!("`RUST_THREADS` is `{}`, should be a positive integer", nstr) } } Non...
identifier_body
util.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 ...
() -> bool { (cfg!(target_os="macos")) && running_on_valgrind() } /// Get's the number of scheduler threads requested by the environment /// either `RUST_THREADS` or `num_cpus`. pub fn default_sched_threads() -> uint { match os::getenv("RUST_THREADS") { Some(nstr) => { let opt_n: Option<uin...
limit_thread_creation_due_to_osx_and_valgrind
identifier_name
util.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 ...
limitless vacuum beyond all thought and entity. Perceptions of the most maddeningly untransmissible sort thronged upon us; perceptions of infinity which at the time convulsed us with joy, yet which are now partly lost to my memory and partly incapable of presentation to others.", _ => "You've met with a terribl...
There was a night when winds from unknown spaces whirled us irresistibly into
random_line_split
moves-based-on-type-exprs.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 ...
(cond: bool) { let x = "hi".to_string(); let y = "ho".to_string(); let _y = match cond { true => x, false => y }; touch(&x); //~ ERROR use of moved value: `x` touch(&y); //~ ERROR use of moved value: `y` } fn f50(cond: bool) { let x = "hi".to_string(); let y = "ho".to_st...
f40
identifier_name
moves-based-on-type-exprs.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 ...
else { y }; touch(&x); //~ ERROR use of moved value: `x` touch(&y); //~ ERROR use of moved value: `y` } fn f40(cond: bool) { let x = "hi".to_string(); let y = "ho".to_string(); let _y = match cond { true => x, false => y }; touch(&x); //~ ERROR use of moved valu...
{ x }
conditional_block
moves-based-on-type-exprs.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn f10() { let x = "hi".to_string(); let _y = Foo { f:x }; touch(&x); //~ ERROR use of moved value: `x` } fn f20() { let x = "hi".to_string(); let _y = (x, 3i); touch(&x); //~ ERROR use of moved value: `x` } fn f21() { let x = vec!(1i, 2, 3); let _y = (*x.get(0), 3i); touch(&x); ...
{}
identifier_body
moves-based-on-type-exprs.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 ...
touch(&x); //~ ERROR use of moved value: `x` touch(&y); //~ ERROR use of moved value: `y` } fn f40(cond: bool) { let x = "hi".to_string(); let y = "ho".to_string(); let _y = match cond { true => x, false => y }; touch(&x); //~ ERROR use of moved value: `x` touch(&y); //~...
random_line_split
cache_aligned.rs
use alloc::heap::{allocate, deallocate}; use std::fmt; use std::mem::size_of; use std::ops::{Deref, DerefMut}; use std::ptr::{self, Unique}; const CACHE_LINE_SIZE: usize = 64; unsafe fn allocate_cache_line(size: usize) -> *mut u8 { allocate(size, CACHE_LINE_SIZE) } pub struct CacheAligned<T: Sized> { ptr: Uni...
(&self) -> &T { unsafe { self.ptr.get() } } } impl<T: Sized> DerefMut for CacheAligned<T> { fn deref_mut(&mut self) -> &mut T { unsafe { self.ptr.get_mut() } } } impl<T: Sized> CacheAligned<T> { pub fn allocate(src: T) -> CacheAligned<T> { unsafe { let alloc = alloc...
deref
identifier_name
cache_aligned.rs
use alloc::heap::{allocate, deallocate}; use std::fmt; use std::mem::size_of; use std::ops::{Deref, DerefMut}; use std::ptr::{self, Unique}; const CACHE_LINE_SIZE: usize = 64; unsafe fn allocate_cache_line(size: usize) -> *mut u8 { allocate(size, CACHE_LINE_SIZE) } pub struct CacheAligned<T: Sized> { ptr: Uni...
}
{ T::fmt(&*self, f) }
identifier_body
cache_aligned.rs
use alloc::heap::{allocate, deallocate};
use std::fmt; use std::mem::size_of; use std::ops::{Deref, DerefMut}; use std::ptr::{self, Unique}; const CACHE_LINE_SIZE: usize = 64; unsafe fn allocate_cache_line(size: usize) -> *mut u8 { allocate(size, CACHE_LINE_SIZE) } pub struct CacheAligned<T: Sized> { ptr: Unique<T>, } impl<T: Sized> Drop for CacheA...
random_line_split
issue-16272.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let status = Command::new(&env::current_exe().unwrap()) .arg("foo").arg("") .status().unwrap(); assert!(status.success()); }
test
identifier_name