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_gecko.rs
path }; static ref SEARCH_PATHS: Vec<PathBuf> = vec![ DISTDIR_PATH.join("include"), DISTDIR_PATH.join("include/nspr"), ]; static ref ADDED_PATHS: Mutex<HashSet<PathBuf>> = Mutex::new(HashSet::new()); static ref LAST_MODIFIED: Mutex<SystemTime> = ...
fn include<T: Into<String>>(self, file: T) -> Builder; fn zero_size_type(self, ty: &str, structs_list: &HashSet<&str>) -> Builder; fn borrowed_type(self, ty: &str) -> Builder; fn mutable_borrowed_type(self, ty: &str) -> Builder; } fn add_clang_args(mut builder: Builder, config: ...
trait BuilderExt { fn get_initial_builder() -> Builder;
random_line_split
build_gecko.rs
path }; static ref SEARCH_PATHS: Vec<PathBuf> = vec![ DISTDIR_PATH.join("include"), DISTDIR_PATH.join("include/nspr"), ]; static ref ADDED_PATHS: Mutex<HashSet<PathBuf>> = Mutex::new(HashSet::new()); static ref LAST_MODIFIED: Mutex<SystemTime> = ...
} } if let Some(path) = env::var_os("STYLO_BUILD_LOG") { log::set_max_level(log::LevelFilter::Debug); log::set_boxed_logger(Box::new(BuildLogger { file: fs::File::create(path).ok().map(Mutex::new), filter: env::var("STYLO_BUILD_FILTER...
{ file.lock().unwrap().flush().unwrap(); }
conditional_block
shell.rs
use std::fmt; use std::io::prelude::*; use termcolor::Color::{Cyan, Green, Red, Yellow}; use termcolor::{self, Color, ColorSpec, StandardStream, WriteColor}; use crate::util::errors::CargoResult; /// The requested verbosity of output. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Verbosity { Verbose, Nor...
(&mut self) -> &mut dyn Write { match *self { ShellOut::Stream { ref mut stream,.. } => stream, ShellOut::Write(ref mut w) => w, } } } impl ColorChoice { /// Converts our color choice to termcolor's version. fn to_termcolor_color_choice(self) -> termcolor::ColorChoic...
as_write
identifier_name
shell.rs
use std::fmt; use std::io::prelude::*; use termcolor::Color::{Cyan, Green, Red, Yellow}; use termcolor::{self, Color, ColorSpec, StandardStream, WriteColor}; use crate::util::errors::CargoResult; /// The requested verbosity of output. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Verbosity { Verbose, Nor...
use winapi::um::winbase::*; use winapi::um::wincon::*; use winapi::um::winnt::*; pub(super) use super::default_err_erase_line as err_erase_line; pub fn stderr_width() -> Option<usize> { unsafe { let stdout = GetStdHandle(STD_ERROR_HANDLE); let mut csbi: CONSOLE_SCRE...
use winapi::um::fileapi::*; use winapi::um::handleapi::*; use winapi::um::processenv::*;
random_line_split
static-method-on-struct-and-enum.rs
// Copyright 2013-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...
{ Variant1 { x: isize }, Variant2, Variant3(f64, isize, char), } impl Enum { fn static_method(arg1: isize, arg2: f64, arg3: usize) -> isize { zzz(); // #break arg1 } } fn main() { Struct::static_method(1, 2); Enum::static_method(-3, 4.5, 5); } fn zzz() {()}
Enum
identifier_name
static-method-on-struct-and-enum.rs
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // min-lldb-version: 310 // compile-flags:-g // === GDB TESTS ========================...
// Copyright 2013-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
random_line_split
record.rs
use std::ops::Deref; use config::gobjects::GObject; use env::Env; use library; use nameutil::*; use super::*; use super::imports::Imports; use super::info_base::InfoBase; use traits::*; #[derive(Default)] pub struct Info { pub base: InfoBase, } impl Deref for Info { type Target = InfoBase; fn deref(&sel...
; special_functions::analyze_imports(&specials, &mut imports); //don't `use` yourself imports.remove(&name); let base = InfoBase { full_name: full_name, type_id: record_tid, name: name, functions: functions, specials: specials, imports: imports, ...
{ // `copy` will duplicate a struct while `clone` just adds a reference special_functions::unhide(&mut functions, &specials, special_functions::Type::Copy); }
conditional_block
record.rs
use std::ops::Deref; use config::gobjects::GObject; use env::Env; use library; use nameutil::*; use super::*; use super::imports::Imports; use super::info_base::InfoBase; use traits::*; #[derive(Default)] pub struct Info { pub base: InfoBase, } impl Deref for Info { type Target = InfoBase; fn deref(&sel...
} pub fn new(env: &Env, obj: &GObject) -> Option<Info> { let full_name = obj.name.clone(); let record_tid = match env.library.find_type(0, &full_name) { Some(tid) => tid, None => return None, }; let type_ = env.type_(record_tid); let name: String = split_namespace_name(&full_nam...
{ let type_ = library.type_(self.type_id).maybe_ref() .unwrap_or_else(|| panic!("{} is not a record.", self.full_name)); type_ }
identifier_body
record.rs
use std::ops::Deref; use config::gobjects::GObject; use env::Env; use library; use nameutil::*; use super::*; use super::imports::Imports; use super::info_base::InfoBase; use traits::*; #[derive(Default)] pub struct Info { pub base: InfoBase, } impl Deref for Info { type Target = InfoBase; fn deref(&sel...
(env: &Env, obj: &GObject) -> Option<Info> { let full_name = obj.name.clone(); let record_tid = match env.library.find_type(0, &full_name) { Some(tid) => tid, None => return None, }; let type_ = env.type_(record_tid); let name: String = split_namespace_name(&full_name).1.into(); ...
new
identifier_name
record.rs
use std::ops::Deref; use config::gobjects::GObject; use env::Env; use library; use nameutil::*; use super::*; use super::imports::Imports; use super::info_base::InfoBase; use traits::*; #[derive(Default)] pub struct Info { pub base: InfoBase, } impl Deref for Info { type Target = InfoBase; fn deref(&sel...
let record: &library::Record = match type_.maybe_ref() { Some(record) => record, None => return None, }; let mut imports = Imports::new(); imports.add("glib::translate::*", None); imports.add("ffi", None); let mut functions = functions::analyze(env, &record.functions, record_ti...
let type_ = env.type_(record_tid); let name: String = split_namespace_name(&full_name).1.into();
random_line_split
get_message_events.rs
//! [GET /_matrix/client/r0/rooms/{roomId}/messages](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-messages) use js_int::UInt; use ruma_api::ruma_api; use ruma_events::{ collections::all::{RoomEvent, StateEvent}, EventJson, }; use ruma_identifiers::RoomId; use serde::{Dese...
() { let room_id = RoomId::try_from("!roomid:example.org").unwrap(); let req = Request { room_id, from: "token".into(), to: Some("token2".into()), dir: Direction::Backward, limit: Some(UInt::from(0u32)), filter: Some(RoomEventFilter...
test_serialize_default_room_event_filter
identifier_name
get_message_events.rs
//! [GET /_matrix/client/r0/rooms/{roomId}/messages](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-messages) use js_int::UInt; use ruma_api::ruma_api; use ruma_events::{ collections::all::{RoomEvent, StateEvent}, EventJson, }; use ruma_identifiers::RoomId; use serde::{Dese...
}
{ let room_id = RoomId::try_from("!roomid:example.org").unwrap(); let req = Request { room_id, from: "token".into(), to: Some("token2".into()), dir: Direction::Backward, limit: Some(UInt::from(0u32)), filter: Some(RoomEventFilter::d...
identifier_body
get_message_events.rs
//! [GET /_matrix/client/r0/rooms/{roomId}/messages](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-messages) use js_int::UInt; use ruma_api::ruma_api; use ruma_events::{ collections::all::{RoomEvent, StateEvent}, EventJson, }; use ruma_identifiers::RoomId; use serde::{Dese...
/// returned by a previous request to this endpoint. #[ruma_api(query)] pub from: String, /// The token to stop returning events at. /// /// This token can be obtained from a prev_batch /// token returned for each room by the sync endpoint, or from a start or end...
/// The token to start returning events from. /// /// This token can be obtained from a /// prev_batch token returned for each room by the sync API, or from a start or end token
random_line_split
layout_debug.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/. */ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to m...
; #[macro_export] macro_rules! layout_debug_scope( ($($arg:tt)*) => ( if cfg!(not(ndebug)) { layout_debug::Scope::new(format!($($arg)*)) } else { layout_debug::Scope } ) ); #[derive(RustcEncodable)] struct ScopeData { name: String, pre: String, post:...
Scope
identifier_name
layout_debug.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/. */ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to m...
}; *r.borrow_mut() = Some(state); }); } /// End the debug layout trace. This will write the layout /// trace to disk in the current directory. The output /// file can then be viewed with an external tool. pub fn end_trace() { let mut task_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unw...
STATE_KEY.with(|ref r| { let flow_trace = json::encode(&flow::base(&*flow_root)).unwrap(); let state = State { scope_stack: vec![box ScopeData::new("root".to_owned(), flow_trace)], flow_root: flow_root.clone(),
random_line_split
layout_debug.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/. */ //! Supports writing a trace file created during each layout scope //! that can be viewed by an external tool to m...
} }); } } /// Generate a unique ID. This is used for items such as Fragment /// which are often reallocated but represent essentially the /// same data. #[allow(unsafe_blocks)] pub fn generate_unique_debug_id() -> u16 { unsafe { DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16 } } /...
{}
conditional_block
issue-13853-5.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// option. This file may not be copied, modified, or distributed // except according to those terms. trait Deserializer<'a> { } trait Deserializable { fn deserialize_token<'a, D: Deserializer<'a>>(_: D, _: &'a str) -> Self; } impl<'a, T: Deserializable> Deserializable for &'a str { //~^ ERROR type parameter ...
// http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
issue-13853-5.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 main() {}
{ }
identifier_body
issue-13853-5.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() {}
main
identifier_name
main.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! The `servo` test application. //! //! Creates a `Servo` instance with a simple implementation of //! the comp...
() { println!( "Cannot start /ports/servo/ on Android. \ Use /support/android/apk/ + /ports/libsimpleservo/ instead" ); }
main
identifier_name
main.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! The `servo` test application. //! //! Creates a `Servo` instance with a simple implementation of //! the comp...
extern crate log; #[cfg(not(target_os = "android"))] include!("non_android_main.rs"); #[cfg(target_os = "android")] pub fn main() { println!( "Cannot start /ports/servo/ on Android. \ Use /support/android/apk/ + /ports/libsimpleservo/ instead" ); }
// Have this here rather than in non_android_main.rs to work around // https://github.com/rust-lang/rust/issues/53205 #[cfg(not(target_os = "android"))] #[macro_use]
random_line_split
main.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ //! The `servo` test application. //! //! Creates a `Servo` instance with a simple implementation of //! the comp...
{ println!( "Cannot start /ports/servo/ on Android. \ Use /support/android/apk/ + /ports/libsimpleservo/ instead" ); }
identifier_body
function-call.rs
// This test does not passed with gdb < 8.0. See #53497. // min-gdb-version: 10.1 // compile-flags:-g // === GDB TESTS =================================================================================== // gdb-command:run // gdb-command:print fun(45, true) // gdb-check:$1 = true // gdb-command:print fun(444, false)...
let _ = r.get_x(); zzz(); // #break } fn fun(x: isize, y: bool) -> bool { y } fn zzz() { () }
fn main() { let _ = fun(4, true); let r = RegularStruct{x: 4};
random_line_split
function-call.rs
// This test does not passed with gdb < 8.0. See #53497. // min-gdb-version: 10.1 // compile-flags:-g // === GDB TESTS =================================================================================== // gdb-command:run // gdb-command:print fun(45, true) // gdb-check:$1 = true // gdb-command:print fun(444, false)...
() { let _ = fun(4, true); let r = RegularStruct{x: 4}; let _ = r.get_x(); zzz(); // #break } fn fun(x: isize, y: bool) -> bool { y } fn zzz() { () }
main
identifier_name
util.rs
#![allow(clippy::declare_interior_mutable_const)] use std::{ cell::{RefCell, RefMut}, cmp, convert::Infallible, io, }; use xitca_web::{ dev::bytes::{Bytes, BytesMut}, http::{ header::{HeaderValue, SERVER}, StatusCode, }, response::{WebResponse, WebResponseBuilder}, }; ...
(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.extend_from_slice(buf); Ok(buf.len()) } #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) } } pub(super) trait QueryParse { fn parse_query(self) -> u16; } impl QueryParse for Option<&str> { fn parse_query(sel...
write
identifier_name
util.rs
#![allow(clippy::declare_interior_mutable_const)] use std::{ cell::{RefCell, RefMut}, cmp, convert::Infallible, io, }; use xitca_web::{ dev::bytes::{Bytes, BytesMut}, http::{ header::{HeaderValue, SERVER}, StatusCode, }, response::{WebResponse, WebResponseBuilder}, }; ...
pub(super) struct AppState<C> { client: C, // a re-usable buffer for write response data. write_buf: RefCell<BytesMut>, } impl<C> AppState<C> { pub(super) fn new(client: C) -> Self { let write_buf = RefCell::new(BytesMut::new()); Self { client, write_buf } } #[inline] pub(s...
cmp::min(500, cmp::max(1, num)) } }
random_line_split
util.rs
#![allow(clippy::declare_interior_mutable_const)] use std::{ cell::{RefCell, RefMut}, cmp, convert::Infallible, io, }; use xitca_web::{ dev::bytes::{Bytes, BytesMut}, http::{ header::{HeaderValue, SERVER}, StatusCode, }, response::{WebResponse, WebResponseBuilder}, }; ...
#[inline] pub(super) fn writer(&self) -> Writer<'_> { Writer(self.write_buf.borrow_mut()) } #[inline] pub(super) fn client(&self) -> &C { &self.client } } pub const SERVER_HEADER_VALUE: HeaderValue = HeaderValue::from_static("TFB"); pub const HTML_HEADER_VALUE: HeaderValue =...
{ let write_buf = RefCell::new(BytesMut::new()); Self { client, write_buf } }
identifier_body
map.rs
#[cfg(feature = "vec_map")] pub use vec_map::{Values, VecMap}; #[cfg(not(feature = "vec_map"))] pub use self::vec_map::{Values, VecMap}; #[cfg(not(feature = "vec_map"))] mod vec_map { use std::collections::btree_map; use std::collections::BTreeMap; use std::fmt::{self, Debug, Formatter}; #[derive(Clo...
pub fn contains_key(&self, key: usize) -> bool { self.inner.contains_key(&key) } pub fn entry(&mut self, key: usize) -> Entry<V> { self.inner.entry(key) } pub fn get(&self, key: usize) -> Option<&V> { self.inner.get(&key) } } ...
{ Iter { inner: self.inner.iter(), } }
identifier_body
map.rs
#[cfg(feature = "vec_map")] pub use vec_map::{Values, VecMap}; #[cfg(not(feature = "vec_map"))] pub use self::vec_map::{Values, VecMap}; #[cfg(not(feature = "vec_map"))] mod vec_map { use std::collections::btree_map; use std::collections::BTreeMap; use std::fmt::{self, Debug, Formatter}; #[derive(Clo...
(&self) -> Values<V> { self.inner.values() } pub fn iter(&self) -> Iter<V> { Iter { inner: self.inner.iter(), } } pub fn contains_key(&self, key: usize) -> bool { self.inner.contains_key(&key) } pub fn ent...
values
identifier_name
map.rs
#[cfg(feature = "vec_map")] pub use vec_map::{Values, VecMap}; #[cfg(not(feature = "vec_map"))] pub use self::vec_map::{Values, VecMap}; #[cfg(not(feature = "vec_map"))] mod vec_map { use std::collections::btree_map; use std::collections::BTreeMap; use std::fmt::{self, Debug, Formatter}; #[derive(Clo...
self.inner.is_empty() } pub fn insert(&mut self, key: usize, value: V) -> Option<V> { self.inner.insert(key, value) } pub fn values(&self) -> Values<V> { self.inner.values() } pub fn iter(&self) -> Iter<V> { Iter { ...
self.inner.len() } pub fn is_empty(&self) -> bool {
random_line_split
pairs.rs
use rustc_ast::ast; use crate::config::lists::*; use crate::config::IndentStyle; use crate::rewrite::{Rewrite, RewriteContext}; use crate::shape::Shape; use crate::utils::{ first_line_width, is_single_line, last_line_width, trimmed_last_line_width, wrap_str, }; /// Sigils that decorate a binop pair. #[derive(new,...
( expr: &ast::Expr, shape: Shape, context: &RewriteContext<'_>, ) -> Option<String> { expr.flatten(context, shape).and_then(|list| { // First we try formatting on one line. rewrite_pairs_one_line(&list, shape, context) .or_else(|| rewrite_pairs_multiline(&list, shape, context)...
rewrite_all_pairs
identifier_name
pairs.rs
use rustc_ast::ast; use crate::config::lists::*; use crate::config::IndentStyle; use crate::rewrite::{Rewrite, RewriteContext}; use crate::shape::Shape; use crate::utils::{ first_line_width, is_single_line, last_line_width, trimmed_last_line_width, wrap_str, }; /// Sigils that decorate a binop pair.
infix: &'a str, suffix: &'a str, } impl<'a> PairParts<'a> { pub(crate) fn infix(infix: &'a str) -> PairParts<'a> { PairParts { prefix: "", infix, suffix: "", } } } // Flattens a tree of pairs into a list and tries to rewrite them all at once. // FIXM...
#[derive(new, Clone, Copy)] pub(crate) struct PairParts<'a> { prefix: &'a str,
random_line_split
traits.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
else { None } } fn size_hint(&self) -> (usize, Option<usize>){ (self.size as usize, Some(self.size as usize)) } fn nth(&mut self, p: usize) -> Option<U>{ if p < self.size as usize { self.index = p as u32; let result = self.list.index_move(se...
{ let result = self.list.index_move(self.index); self.index += 1; Some(result) }
conditional_block
traits.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
pub trait HasStructSize { fn struct_size() -> StructSize; } pub trait IntoInternalStructReader<'a> { fn into_internal_struct_reader(self) -> StructReader<'a>; } pub trait FromStructBuilder<'a> { fn new(struct_builder: StructBuilder<'a>) -> Self; } pub trait IntoInternalListReader<'a> { fn into_inter...
pub trait FromStructReader<'a> { fn new(reader: StructReader<'a>) -> Self; }
random_line_split
traits.rs
// Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors // Licensed under the MIT License: // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, inc...
(&mut self, p: usize) -> Option<U>{ if p < self.size as usize { self.index = p as u32; let result = self.list.index_move(self.index); Some(result) } else { None } } } impl <U, T: IndexMove<u32, U>> ::std::iter::ExactSizeIterator for ListIter<T...
nth
identifier_name
header.rs
// Copyright 2012-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-MI...
// Load any test directives embedded in the file pub fn load_props(testfile: &Path) -> TestProps { let mut error_patterns = ~[]; let mut aux_builds = ~[]; let mut exec_env = ~[]; let mut compile_flags = None; let mut pp_exact = None; let mut debugger_cmds = ~[]; let mut check_lines = ~[]; ...
}
random_line_split
header.rs
// Copyright 2012-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-MI...
} match parse_exec_env(ln) { Some(ee) => { exec_env.push(ee); } None => {} } match parse_debugger_cmd(ln) { Some(dc) => debugger_cmds.push(dc), None => () }; match parse_check_line(ln) { Some(cl) => check_lin...
{}
conditional_block
header.rs
// Copyright 2012-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-MI...
fn parse_name_directive(line: &str, directive: &str) -> bool { str::contains(line, directive) } fn parse_name_value_directive(line: &str, directive: ~str) -> Option<~str> { let keycolon = directive + ~":"; match str::find_str(line, keycolon) { Some(colon) => { ...
{ match parse_name_value_directive(line, ~"pp-exact") { Some(s) => Some(Path(s)), None => { if parse_name_directive(line, "pp-exact") { Some(testfile.file_path()) } else { None } } } }
identifier_body
header.rs
// Copyright 2012-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-MI...
(testfile: &Path) -> TestProps { let mut error_patterns = ~[]; let mut aux_builds = ~[]; let mut exec_env = ~[]; let mut compile_flags = None; let mut pp_exact = None; let mut debugger_cmds = ~[]; let mut check_lines = ~[]; for iter_header(testfile) |ln| { match parse_error_patte...
load_props
identifier_name
lib.rs
//! Kleene logic within Rust's type system //! //! Values are `True`, `False` and `Unknown`. Operations are `Not`, `BitAnd` //! and `BitOr` from `std::ops`. There is also the `Ternary` enum which //! represents the values at runtime and the `ToTernary` trait that adds the //! `to_ternary()` methods to our value types....
} /// Unknown & False == False impl BitAnd<False> for Unknown { type Output = False; fn bitand(self, _: False) -> Self::Output { match self {} } } /// BitOr /// True | X == True impl<X: ToTernary> BitOr<X> for True { type Output = True; fn bitor(self, _: X) -> Self::Output { match self {} } } /// ...
{ match self {} }
identifier_body
lib.rs
//! Kleene logic within Rust's type system //! //! Values are `True`, `False` and `Unknown`. Operations are `Not`, `BitAnd` //! and `BitOr` from `std::ops`. There is also the `Ternary` enum which //! represents the values at runtime and the `ToTernary` trait that adds the //! `to_ternary()` methods to our value types....
impl BitAnd<True> for Unknown { type Output = Unknown; fn bitand(self, _: True) -> Self::Output { match self {} } } /// Unknown & Unknown == Unknown impl BitAnd<Unknown> for Unknown { type Output = Unknown; fn bitand(self, _: Unknown) -> Self::Output { match self {} } } /// Unknown & False == False im...
/// Unknown & True == Unknown
random_line_split
lib.rs
//! Kleene logic within Rust's type system //! //! Values are `True`, `False` and `Unknown`. Operations are `Not`, `BitAnd` //! and `BitOr` from `std::ops`. There is also the `Ternary` enum which //! represents the values at runtime and the `ToTernary` trait that adds the //! `to_ternary()` methods to our value types....
(self, _: X) -> Self::Output { match self {} } } /// Unknown & True == Unknown impl BitAnd<True> for Unknown { type Output = Unknown; fn bitand(self, _: True) -> Self::Output { match self {} } } /// Unknown & Unknown == Unknown impl BitAnd<Unknown> for Unknown { type Output = Unknown; fn bitand(self, ...
bitand
identifier_name
part1.rs
// adventofcode - day 15 // part 1 use std::io::prelude::*; use std::fs::File; struct Ingredient { #[allow(dead_code)] name: String, capacity: i32, durability: i32, flavour: i32, texture: i32, #[allow(dead_code)] calories: i32, } fn main(){ println!("Advent of Code - day 15 | part...
} fn calculate_recipe(ingredients: &Vec<Ingredient>, teaspoons: &Vec<i32>) -> i32{ let mut capacity = 0; let mut durability = 0; let mut flavour = 0; let mut texture = 0; for ii in 0..ingredients.len() { capacity += ingredients[ii].capacity * teaspoons[ii]; durability += ingredient...
random_line_split
part1.rs
// adventofcode - day 15 // part 1 use std::io::prelude::*; use std::fs::File; struct Ingredient { #[allow(dead_code)] name: String, capacity: i32, durability: i32, flavour: i32, texture: i32, #[allow(dead_code)] calories: i32, } fn main(){ println!("Advent of Code - day 15 | part...
{ let mut file = match File::open("../../inputs/15.txt") { Ok(f) => f, Err(e) => panic!("file error: {}", e), }; let mut data = String::new(); match file.read_to_string(&mut data){ Ok(_) => {}, Err(e) => panic!("file error: {}", e), }; data }
identifier_body
part1.rs
// adventofcode - day 15 // part 1 use std::io::prelude::*; use std::fs::File; struct Ingredient { #[allow(dead_code)] name: String, capacity: i32, durability: i32, flavour: i32, texture: i32, #[allow(dead_code)] calories: i32, } fn main(){ println!("Advent of Code - day 15 | part...
(line: &str) -> Ingredient { let properties = line.split(": capacity ") .map(|s| s.parse::<String>().unwrap()) .collect::<Vec<String>>(); let name = properties[0].clone(); let properties = properties[1].split(", durability ") .flat_map(|...
parse_line
identifier_name
issue-50814-2.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
// option. This file may not be copied, modified, or distributed // except according to those terms. trait C { const BOO: usize; } trait Foo<T> { const BAR: usize; } struct A<T>(T); impl<T: C> Foo<T> for A<T> { const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR any use of this value will cause an error } ...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
issue-50814-2.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 ...
<T: C>() -> &'static usize { &<A<T> as Foo<T>>::BAR //~ ERROR E0080 } impl C for () { const BOO: usize = 42; } impl C for u32 { const BOO: usize = 1; } fn main() { println!("{:x}", foo::<()>() as *const usize as usize); println!("{:x}", foo::<u32>() as *const usize as usize); println!("{:x}",...
foo
identifier_name
arrow.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use ArrowType; use Buildable; use Misc; use ShadowType; use Widget; use ffi; use glib::StaticType; use glib::Value; use glib::object::Cast; use glib::object::IsA; use glib::signal::S...
fn connect_property_arrow_type_notify<F: Fn(&Self) +'static>(&self, f: F) -> SignalHandlerId { unsafe { let f: Box_<F> = Box_::new(f); connect_raw(self.as_ptr() as *mut _, b"notify::arrow-type\0".as_ptr() as *const _, Some(transmute(notify_arrow_type_trampoline::<Se...
{ unsafe { gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"shadow-type\0".as_ptr() as *const _, Value::from(&shadow_type).to_glib_none().0); } }
identifier_body
arrow.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use ArrowType; use Buildable; use Misc; use ShadowType; use Widget; use ffi; use glib::StaticType; use glib::Value; use glib::object::Cast; use glib::object::IsA; use glib::signal::S...
} fn get_property_shadow_type(&self) -> ShadowType { unsafe { let mut value = Value::from_type(<ShadowType as StaticType>::static_type()); gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"shadow-type\0".as_ptr() as *const _, value.to_glib_...
}
random_line_split
arrow.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use ArrowType; use Buildable; use Misc; use ShadowType; use Widget; use ffi; use glib::StaticType; use glib::Value; use glib::object::Cast; use glib::object::IsA; use glib::signal::S...
<F: Fn(&Self) +'static>(&self, f: F) -> SignalHandlerId { unsafe { let f: Box_<F> = Box_::new(f); connect_raw(self.as_ptr() as *mut _, b"notify::shadow-type\0".as_ptr() as *const _, Some(transmute(notify_shadow_type_trampoline::<Self, F> as usize)), Box_::into_raw(f)) ...
connect_property_shadow_type_notify
identifier_name
package.rs
use std::cell::{Ref, RefCell}; use std::collections::HashMap; use std::fmt; use std::hash; use std::path::{Path, PathBuf}; use semver::Version; use core::{Dependency, Manifest, PackageId, SourceId, Target, TargetKind}; use core::{Summary, Metadata, SourceMap}; use ops; use util::{CargoResult, Config, LazyCell, ChainE...
let mut sources = self.sources.borrow_mut(); let source = try!(sources.get_mut(id.source_id()).chain_error(|| { internal(format!("couldn't find source for `{}`", id)) })); let pkg = try!(source.download(id).chain_error(|| { human("unable to get packages from sour...
{ return Ok(pkg) }
conditional_block
package.rs
use std::cell::{Ref, RefCell}; use std::collections::HashMap; use std::fmt; use std::hash; use std::path::{Path, PathBuf}; use semver::Version; use core::{Dependency, Manifest, PackageId, SourceId, Target, TargetKind}; use core::{Summary, Metadata, SourceMap}; use ops; use util::{CargoResult, Config, LazyCell, ChainE...
} impl Eq for Package {} impl hash::Hash for Package { fn hash<H: hash::Hasher>(&self, into: &mut H) { self.package_id().hash(into) } } pub struct PackageSet<'cfg> { packages: Vec<(PackageId, LazyCell<Package>)>, sources: RefCell<SourceMap<'cfg>>, } impl<'cfg> PackageSet<'cfg> { pub fn n...
impl PartialEq for Package { fn eq(&self, other: &Package) -> bool { self.package_id() == other.package_id() }
random_line_split
package.rs
use std::cell::{Ref, RefCell}; use std::collections::HashMap; use std::fmt; use std::hash; use std::path::{Path, PathBuf}; use semver::Version; use core::{Dependency, Manifest, PackageId, SourceId, Target, TargetKind}; use core::{Summary, Metadata, SourceMap}; use ops; use util::{CargoResult, Config, LazyCell, ChainE...
} impl Eq for Package {} impl hash::Hash for Package { fn hash<H: hash::Hasher>(&self, into: &mut H) { self.package_id().hash(into) } } pub struct PackageSet<'cfg> { packages: Vec<(PackageId, LazyCell<Package>)>, sources: RefCell<SourceMap<'cfg>>, } impl<'cfg> PackageSet<'cfg> { pub fn ...
{ self.package_id() == other.package_id() }
identifier_body
package.rs
use std::cell::{Ref, RefCell}; use std::collections::HashMap; use std::fmt; use std::hash; use std::path::{Path, PathBuf}; use semver::Version; use core::{Dependency, Manifest, PackageId, SourceId, Target, TargetKind}; use core::{Summary, Metadata, SourceMap}; use ops; use util::{CargoResult, Config, LazyCell, ChainE...
(&self, id: &PackageId) -> CargoResult<&Package> { let slot = try!(self.packages.iter().find(|p| p.0 == *id).chain_error(|| { internal(format!("couldn't find `{}` in package set", id)) })); let slot = &slot.1; if let Some(pkg) = slot.borrow() { return Ok(pkg) ...
get
identifier_name
webgl_paint_thread.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 canvas_traits::{CanvasCommonMsg, CanvasData, CanvasMsg, CanvasPixelData}; use canvas_traits::{FromLayoutMsg, b...
/// Creates a new `WebGLPaintThread` and returns an `IpcSender` to /// communicate with it. pub fn start(size: Size2D<i32>, attrs: GLContextAttributes, webrender_api_sender: Option<webrender_traits::RenderApiSender>) -> Result<(IpcSender<CanvasMsg>, GLLim...
{ debug!("WebGL message: {:?}", message); match self.data { WebGLPaintTaskData::WebRender(ref api, id) => { api.send_webgl_command(id, message); } WebGLPaintTaskData::Readback(ref ctx, _) => { message.apply(ctx); } }...
identifier_body
webgl_paint_thread.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 canvas_traits::{CanvasCommonMsg, CanvasData, CanvasMsg, CanvasPixelData}; use canvas_traits::{FromLayoutMsg, b...
thread }, Err(e) => { result_chan.send(Err(e)).unwrap(); return } }; painter.init(); loop { match receiver.recv().unwrap() { CanvasMsg::WebG...
let (result_chan, result_port) = channel(); spawn_named("WebGLThread".to_owned(), move || { let mut painter = match WebGLPaintThread::new(size, attrs, webrender_api_sender) { Ok((thread, limits)) => { result_chan.send(Ok(limits)).unwrap();
random_line_split
webgl_paint_thread.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 canvas_traits::{CanvasCommonMsg, CanvasData, CanvasMsg, CanvasPixelData}; use canvas_traits::{FromLayoutMsg, b...
(&mut self, chan: IpcSender<CanvasData>) { match self.data { WebGLPaintTaskData::Readback(_, ref webrender_api_and_image_key) => { let width = self.size.width as usize; let height = self.size.height as usize; let mut pixels = gl::read_pixels(0, 0, ...
send_data
identifier_name
kahansum.rs
// Implements http://rosettacode.org/wiki/Kahan_summation #![feature(std_misc)] #![feature(collections)] use std::num::Float; use std::f32; fn
(lst: &[f32]) -> Option<f32> { if lst.is_empty() { return None } let max = lst.iter().fold(f32::NEG_INFINITY, |a, &b| Float::max(a, b)); Some(max) } fn with_bits(val: f32, digits: usize) -> f32 { let num = std::f32::to_str_digits(val, digits); num.parse::<f32>().unwrap...
find_max
identifier_name
kahansum.rs
// Implements http://rosettacode.org/wiki/Kahan_summation #![feature(std_misc)] #![feature(collections)] use std::num::Float; use std::f32; fn find_max(lst: &[f32]) -> Option<f32> { if lst.is_empty() { return None } let max = lst.iter().fold(f32::NEG_INFINITY, |a, &b| Float::max(...
let mut res = Vec::new(); let mut perms = vec.permutations(); loop { let v = perms.next(); match v { Some(_v) => { let mut sum = 0.0f32; for e in &_v { sum += with_bits(*e, 1); } res.push(with_bi...
fn all_sums(vec: &[f32]) -> Vec<f32> {
random_line_split
kahansum.rs
// Implements http://rosettacode.org/wiki/Kahan_summation #![feature(std_misc)] #![feature(collections)] use std::num::Float; use std::f32; fn find_max(lst: &[f32]) -> Option<f32> { if lst.is_empty()
let max = lst.iter().fold(f32::NEG_INFINITY, |a, &b| Float::max(a, b)); Some(max) } fn with_bits(val: f32, digits: usize) -> f32 { let num = std::f32::to_str_digits(val, digits); num.parse::<f32>().unwrap() } fn kahan_sum(lst: &[f32]) -> Option<f32> { let mut sum = 0...
{ return None }
conditional_block
kahansum.rs
// Implements http://rosettacode.org/wiki/Kahan_summation #![feature(std_misc)] #![feature(collections)] use std::num::Float; use std::f32; fn find_max(lst: &[f32]) -> Option<f32> { if lst.is_empty() { return None } let max = lst.iter().fold(f32::NEG_INFINITY, |a, &b| Float::max(...
#[test] fn test_withbits() { let v = 3.123345f32; let res = with_bits(v, 3); assert!(res == 3.123f32); }
{ let v = [10000.0f32, 3.14159, 2.71828]; let sums = all_sums(&v); let res = kahan_sum(&v).unwrap(); let max = find_max(&sums[..]).unwrap(); assert!(max < res); }
identifier_body
conversions.rs
// Copyright (c) 2016-2018 Bruce Stenning. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of co...
pub fn radians_to_degrees(radians: f32) -> f32 { radians * 180.0f32 / f32::consts::PI }
random_line_split
conversions.rs
// Copyright (c) 2016-2018 Bruce Stenning. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of co...
{ radians * 180.0f32 / f32::consts::PI }
identifier_body
conversions.rs
// Copyright (c) 2016-2018 Bruce Stenning. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of co...
(radians: f32) -> f32 { radians * 180.0f32 / f32::consts::PI }
radians_to_degrees
identifier_name
windowing.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/. */ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. use compositor...
{ Forward, Back, } /// Events that the windowing system sends to Servo. #[derive(Clone)] pub enum WindowEvent { /// Sent when no message has arrived, but the event loop was kicked for some reason (perhaps /// by another Servo subsystem). /// /// FIXME(pcwalton): This is kind of ugly and may no...
WindowNavigateMsg
identifier_name
windowing.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/. */ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. use compositor...
/// by another Servo subsystem). /// /// FIXME(pcwalton): This is kind of ugly and may not work well with multiprocess Servo. /// It's possible that this should be something like /// `CompositorMessageWindowEvent(compositor_thread::Msg)` instead. Idle, /// Sent when part of the window is mar...
/// Events that the windowing system sends to Servo. #[derive(Clone)] pub enum WindowEvent { /// Sent when no message has arrived, but the event loop was kicked for some reason (perhaps
random_line_split
system.rs
use std::sync::RwLock; use std::path::{Path, PathBuf}; use std::fs; use slog::Logger; use search::backends::rocksdb::RocksDBStore; use uuid::Uuid; use index::Index; use index::metadata::IndexMetadata; use cluster::metadata::ClusterMetadata; pub struct System { pub log: Logger, data_dir: PathBuf, pub met...
(&self) -> PathBuf { let mut dir = self.data_dir.clone(); dir.push("indices"); dir } fn load_index(&self, id: Uuid, name: String, path: &Path) -> Result<Index, String> { let store = RocksDBStore::open(path)?; // Load metadata let mut metadata_path = path.to_path...
get_indices_dir
identifier_name
system.rs
use std::sync::RwLock; use std::path::{Path, PathBuf}; use std::fs; use slog::Logger; use search::backends::rocksdb::RocksDBStore; use uuid::Uuid; use index::Index; use index::metadata::IndexMetadata; use cluster::metadata::ClusterMetadata; pub struct System { pub log: Logger, data_dir: PathBuf, pub met...
} } Err(error) => { error!(self.log, "could not open indices directory"; "dir" => indices_dir.to_str().unwrap(), "error" => format!("{}", error)); } } } }
}
random_line_split
system.rs
use std::sync::RwLock; use std::path::{Path, PathBuf}; use std::fs; use slog::Logger; use search::backends::rocksdb::RocksDBStore; use uuid::Uuid; use index::Index; use index::metadata::IndexMetadata; use cluster::metadata::ClusterMetadata; pub struct System { pub log: Logger, data_dir: PathBuf, pub met...
} } } } Err(error) => { error!(self.log, "could not open indices directory"; "dir" => indices_dir.to_str().unwrap(), "error" => format!("{}", error)); } } } }
{ error!(self.log, "load index failed"; "index" => index_name, "error" => e); }
conditional_block
system.rs
use std::sync::RwLock; use std::path::{Path, PathBuf}; use std::fs; use slog::Logger; use search::backends::rocksdb::RocksDBStore; use uuid::Uuid; use index::Index; use index::metadata::IndexMetadata; use cluster::metadata::ClusterMetadata; pub struct System { pub log: Logger, data_dir: PathBuf, pub met...
pub fn get_indices_dir(&self) -> PathBuf { let mut dir = self.data_dir.clone(); dir.push("indices"); dir } fn load_index(&self, id: Uuid, name: String, path: &Path) -> Result<Index, String> { let store = RocksDBStore::open(path)?; // Load metadata let mut ...
{ System { log: log, data_dir: data_dir, metadata: RwLock::new(ClusterMetadata::new()), } }
identifier_body
macros-nested.rs
// This test is similar to `macros.rs`, but nested in modules. // run-pass // edition:2018
#![allow(non_camel_case_types)] mod foo { // Test that ambiguity errors are not emitted between `self::test` and // `::test`, assuming the latter (crate) is not in `extern_prelude`. macro_rules! m1 { () => { mod test { pub struct Foo(pub ()); } } ...
random_line_split
macros-nested.rs
// This test is similar to `macros.rs`, but nested in modules. // run-pass // edition:2018 #![allow(non_camel_case_types)] mod foo { // Test that ambiguity errors are not emitted between `self::test` and // `::test`, assuming the latter (crate) is not in `extern_prelude`. macro_rules! m1 { () => ...
{ foo::Foo(()); let _ = foo::std_io::stdout(); foo::local_io(()); let _ = io::stdout(); let _ = bar::io::stdout(); }
identifier_body
macros-nested.rs
// This test is similar to `macros.rs`, but nested in modules. // run-pass // edition:2018 #![allow(non_camel_case_types)] mod foo { // Test that ambiguity errors are not emitted between `self::test` and // `::test`, assuming the latter (crate) is not in `extern_prelude`. macro_rules! m1 { () => ...
() { foo::Foo(()); let _ = foo::std_io::stdout(); foo::local_io(()); let _ = io::stdout(); let _ = bar::io::stdout(); }
main
identifier_name
textdecoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::TextDecoderBinding; use crate::dom::bindings::codegen::Bindings::Tex...
// https://encoding.spec.whatwg.org/#dom-textdecoder-ignorebom fn IgnoreBOM(&self) -> bool { self.ignoreBOM } // https://encoding.spec.whatwg.org/#dom-textdecoder-decode fn Decode( &self, input: Option<ArrayBufferViewOrArrayBuffer>, options: &TextDecodeOptions, ...
{ self.fatal }
identifier_body
textdecoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::TextDecoderBinding; use crate::dom::bindings::codegen::Bindings::Tex...
( &self, input: Option<ArrayBufferViewOrArrayBuffer>, options: &TextDecodeOptions, ) -> Fallible<USVString> { // Step 1. if!self.do_not_flush.get() { if self.ignoreBOM { self.decoder .replace(self.encoding.new_decoder_without_bom...
Decode
identifier_name
textdecoder.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::TextDecoderBinding; use crate::dom::bindings::codegen::Bindings::Tex...
// Step 4. let mut out_stream = String::with_capacity( decoder .max_utf8_buffer_length_without_replacement(in_stream.len()) .unwrap(), ); // Step 5: Implemented by encoding_rs::Decoder. ...
let (remaining, s) = if self.fatal {
random_line_split
no_0023_merge_k_sorted_lists.rs
// Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } use std::cmp::{Ord, Ordering, PartialEq}; use std::colle...
node(ListNode { val: 1, next: node(ListNode { val: 4, next: node(ListNode::new(5)), }), }), node(ListNode { val: 1, next: node(ListNode { val: 3...
let lists = vec![
random_line_split
no_0023_merge_k_sorted_lists.rs
// Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } use std::cmp::{Ord, Ordering, PartialEq}; use std::colle...
.next } // 这种是利用数组来生成最终的结果,因为不知道怎么在链表后面插入元素。 pub fn merge_k_lists1(lists: Vec<Option<Box<ListNode>>>) -> Option<Box<ListNode>> { if lists.is_empty() { return None; } // 用数组来暂存结果。 let mut ans = Vec::new(); let mut heap = BinaryHeap::new(); // 把第一列...
r.next.as_mut().unwrap(); } ans
conditional_block
no_0023_merge_k_sorted_lists.rs
// Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } impl ListNode { #[inline] fn
(val: i32) -> Self { ListNode { next: None, val } } } use std::cmp::{Ord, Ordering, PartialEq}; use std::collections::BinaryHeap; impl Ord for ListNode { fn cmp(&self, other: &Self) -> Ordering { // 默认是最大堆,这里颠倒顺序,实现最小堆。 other.val.cmp(&self.val) } } impl PartialOrd for ListNode { ...
new
identifier_name
no_0023_merge_k_sorted_lists.rs
// Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } use std::cmp::{Ord, Ordering, PartialEq}; use std::colle...
n partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) } } struct Solution; impl Solution { pub fn merge_k_lists(lists: Vec<Option<Box<ListNode>>>) -> Option<Box<ListNode>> { if lists.is_empty() { return None; } let mut ans = Box::new(ListNod...
{ // 默认是最大堆,这里颠倒顺序,实现最小堆。 other.val.cmp(&self.val) } } impl PartialOrd for ListNode { f
identifier_body
autoderef-method-priority.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 = box(GC) 3u; assert_eq!(x.double(), 6u); }
main
identifier_name
autoderef-method-priority.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 ...
impl double for uint { fn double(self) -> uint { self } } impl double for Gc<uint> { fn double(self) -> uint { *self * 2u } } pub fn main() { let x = box(GC) 3u; assert_eq!(x.double(), 6u); }
random_line_split
autoderef-method-priority.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 ...
} impl double for Gc<uint> { fn double(self) -> uint { *self * 2u } } pub fn main() { let x = box(GC) 3u; assert_eq!(x.double(), 6u); }
{ self }
identifier_body
wmap.rs
#[macro_use] extern crate cli_util; extern crate wlib; use std::env; use wlib::window;
#[derive(Copy, Clone)] enum Mode { Map, Unmap } fn main() { let name = cli_util::name(&mut env::args()); parse_args!{ description: "map or unmap window", flag mode: Mode = Mode::Map, (&["-m", "--map"], Mode::Map, "map window (default)"), (&["-u", "--unmap"], Mod...
random_line_split
wmap.rs
#[macro_use] extern crate cli_util; extern crate wlib; use std::env; use wlib::window; #[derive(Copy, Clone)] enum Mode { Map, Unmap } fn main() { let name = cli_util::name(&mut env::args()); parse_args!{ description: "map or unmap window", flag mode: Mode = Mode::Map, (&...
(mode: Mode, wid: window::ID) -> Result<(), &'static str> { let disp = try!(wlib::Display::open()); let mut win = try!( disp.window(wid).map_err(|_| "window does not exist") ); match mode { Mode::Map => try!(win.map()), Mode::Unmap => try!(win.unmap()) } Ok(()) }
run
identifier_name
pin.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
/// Pin functions (GPIO or up to three additional functions). #[derive(PartialEq)] #[allow(missing_docs)] pub enum Function { Gpio = 0, AltFunction1 = 1, AltFunction2 = 2, AltFunction3 = 3, } impl Copy for Function {} /// Structure to describe the location of a pin #[derive(Copy)] pub struct Pin { ...
Port4, }
random_line_split
pin.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
fn get_pinsel_reg_and_offset(&self) -> (u8, &reg::PINSEL) { match self.port { Port0 => match self.pin { 0...15 => (self.pin, &reg::PINSEL0), 16...30 => (self.pin-16, &reg::PINSEL1), _ => unsafe { abort() }, }, Port1 => match self.pin { 0...15 => (self....
{ match self.port { Port0 => &reg::GPIO_0, Port1 => &reg::GPIO_1, Port2 => &reg::GPIO_2, Port3 => &reg::GPIO_3, Port4 => &reg::GPIO_4, } }
identifier_body
pin.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com> // // 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.o...
{ /// Port the pin is attached to port: Port, /// Pin number in the port pin: u8 } impl Pin { /// Create and setup a Pin pub fn new(port: Port, pin_index: u8, function: Function, gpiodir: Option<::hal::pin::GpioDirection>) -> Pin { let pin = Pin { port: port, pin: pin_index, }; ...
Pin
identifier_name
unboxed-closures-all-traits.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 main() { let z: int = 7; assert_eq!(a(move |x: int, y| x + y + z), 10); assert_eq!(b(move |x: int, y| x + y + z), 14); assert_eq!(c(move |x: int, y| x + y + z), 18); }
fn c<F:FnOnce(int, int) -> int>(f: F) -> int { f(5, 6) }
random_line_split
unboxed-closures-all-traits.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<F:FnMut(int, int) -> int>(mut f: F) -> int { f(3, 4) } fn c<F:FnOnce(int, int) -> int>(f: F) -> int { f(5, 6) } fn main() { let z: int = 7; assert_eq!(a(move |x: int, y| x + y + z), 10); assert_eq!(b(move |x: int, y| x + y + z), 14); assert_eq!(c(move |x: int, y| x + y + z), 18); }
b
identifier_name
unboxed-closures-all-traits.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 c<F:FnOnce(int, int) -> int>(f: F) -> int { f(5, 6) } fn main() { let z: int = 7; assert_eq!(a(move |x: int, y| x + y + z), 10); assert_eq!(b(move |x: int, y| x + y + z), 14); assert_eq!(c(move |x: int, y| x + y + z), 18); }
{ f(3, 4) }
identifier_body
suggestions.rs
use app::App; // Third Party #[cfg(feature = "suggestions")] use strsim; // Internal use fmt::Format; /// Produces a string from a given list of possible values which is similar to /// the passed in value `v` with a certain confidence. /// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yi...
<'z, T, I>( arg: &str, args_rest: &'z [&str], longs: I, subcommands: &'z [App], ) -> (String, Option<&'z str>) where T: AsRef<str> + 'z, I: IntoIterator<Item = &'z T>, { if let Some(candidate) = did_you_mean(arg, longs) { let suffix = format!( "\n\tDid you mean {}{}?", ...
did_you_mean_flag_suffix
identifier_name
suggestions.rs
use app::App; // Third Party #[cfg(feature = "suggestions")] use strsim; // Internal use fmt::Format; /// Produces a string from a given list of possible values which is similar to /// the passed in value `v` with a certain confidence. /// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yi...
subcommands .into_iter() .filter_map(|subcommand| { let opts = subcommand .p .flags .iter() .filter_map(|f| f.s.long) .chain(subcommand.p.opts.iter().filter_map(|o| o.s.long)); let candidate = match d...
{ let suffix = format!( "\n\tDid you mean {}{}?", Format::Good("--"), Format::Good(candidate) ); return (suffix, Some(candidate)); }
conditional_block
suggestions.rs
use app::App; // Third Party #[cfg(feature = "suggestions")] use strsim; // Internal use fmt::Format; /// Produces a string from a given list of possible values which is similar to /// the passed in value `v` with a certain confidence. /// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yi...
/// Returns a suffix that can be empty, or is the standard 'did you mean' phrase #[cfg_attr(feature = "lints", allow(needless_lifetimes))] pub fn did_you_mean_flag_suffix<'z, T, I>( arg: &str, args_rest: &'z [&str], longs: I, subcommands: &'z [App], ) -> (String, Option<&'z str>) where T: AsRef<st...
{ None }
identifier_body
suggestions.rs
use app::App; // Third Party #[cfg(feature = "suggestions")] use strsim; // Internal use fmt::Format; /// Produces a string from a given list of possible values which is similar to /// the passed in value `v` with a certain confidence. /// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yi...
I: IntoIterator<Item = &'a T>, { None } /// Returns a suffix that can be empty, or is the standard 'did you mean' phrase #[cfg_attr(feature = "lints", allow(needless_lifetimes))] pub fn did_you_mean_flag_suffix<'z, T, I>( arg: &str, args_rest: &'z [&str], longs: I, subcommands: &'z [App], ) -> ...
pub fn did_you_mean<'a, T: ?Sized, I>(_: &str, _: I) -> Option<&'a str> where T: AsRef<str> + 'a,
random_line_split
attr.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 cssparser::RGBA; use std::ops::Deref; use string_cache::{Atom, Namespace}; use util::str::{DOMString, LengthOr...
pub fn from_atomic(string: DOMString) -> AttrValue { // FIXME(ajeffrey): convert directly from DOMString to Atom let value = Atom::from(&*string); AttrValue::Atom(value) } pub fn from_legacy_color(string: DOMString) -> AttrValue { let parsed = parse_legacy_color(&string).ok...
AttrValue::UInt(string, result) }
random_line_split
attr.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 cssparser::RGBA; use std::ops::Deref; use string_cache::{Atom, Namespace}; use util::str::{DOMString, LengthOr...
(string: DOMString) -> AttrValue { let parsed = parse_legacy_color(&string).ok(); AttrValue::Color(string, parsed) } pub fn from_dimension(string: DOMString) -> AttrValue { let parsed = parse_length(&string); AttrValue::Dimension(string, parsed) } /// Assumes the `AttrV...
from_legacy_color
identifier_name
attr.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 cssparser::RGBA; use std::ops::Deref; use string_cache::{Atom, Namespace}; use util::str::{DOMString, LengthOr...
// https://html.spec.whatwg.org/multipage/#reflecting-content-attributes-in-idl-attributes:idl-unsigned-long pub fn from_u32(string: DOMString, default: u32) -> AttrValue { let result = parse_unsigned_integer(string.chars()).unwrap_or(default); let result = if result > UNSIGNED_LONG_MAX { ...
{ // TODO(ajeffrey): effecient conversion of Vec<Atom> to DOMString let tokens = DOMString::from(str_join(&atoms, "\x20")); AttrValue::TokenList(tokens, atoms) }
identifier_body
unsized7.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 ...
trait T {} // I would like these to fail eventually. // impl - bounded trait T1<Z: T> { } struct S3<Y:?Sized>; impl<X:?Sized + T> T1<X> for S3<X> { //~^ ERROR `core::marker::Sized` is not implemented for the type `X` } fn main() { }
// option. This file may not be copied, modified, or distributed // except according to those terms. // Test sized-ness checking in substitution in impls.
random_line_split
unsized7.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { }
main
identifier_name